mirror of
https://github.com/restic/restic.git
synced 2026-07-09 16:55:10 +00:00
restore: add --delete option to remove files that are not in snapshot
This commit is contained in:
@@ -51,6 +51,7 @@ type RestoreOptions struct {
|
||||
Sparse bool
|
||||
Verify bool
|
||||
Overwrite restorer.OverwriteBehavior
|
||||
Delete bool
|
||||
}
|
||||
|
||||
var restoreOptions RestoreOptions
|
||||
@@ -69,6 +70,7 @@ func init() {
|
||||
flags.BoolVar(&restoreOptions.Sparse, "sparse", false, "restore files as sparse")
|
||||
flags.BoolVar(&restoreOptions.Verify, "verify", false, "verify restored files content")
|
||||
flags.Var(&restoreOptions.Overwrite, "overwrite", "overwrite behavior, one of (always|if-changed|if-newer|never) (default: always)")
|
||||
flags.BoolVar(&restoreOptions.Delete, "delete", false, "delete files from target directory if they do not exist in snapshot. Use '--dry-run -vv' to check what would be deleted")
|
||||
}
|
||||
|
||||
func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
|
||||
@@ -149,6 +151,7 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
|
||||
Sparse: opts.Sparse,
|
||||
Progress: progress,
|
||||
Overwrite: opts.Overwrite,
|
||||
Delete: opts.Delete,
|
||||
})
|
||||
|
||||
totalErrors := 0
|
||||
|
||||
Reference in New Issue
Block a user