mirror of
https://github.com/restic/restic.git
synced 2025-10-26 11:08:39 +00:00
backup: allow excluding online-only cloud files
This commit is contained in:
committed by
Michael Eischer
parent
de3acd7937
commit
da71e77b28
@@ -77,6 +77,7 @@ type BackupOptions struct {
|
||||
ExcludeIfPresent []string
|
||||
ExcludeCaches bool
|
||||
ExcludeLargerThan string
|
||||
ExcludeCloudFiles bool
|
||||
Stdin bool
|
||||
StdinFilename string
|
||||
StdinCommand bool
|
||||
@@ -140,6 +141,7 @@ func init() {
|
||||
f.BoolVar(&backupOptions.NoScan, "no-scan", false, "do not run scanner to estimate size of backup")
|
||||
if runtime.GOOS == "windows" {
|
||||
f.BoolVar(&backupOptions.UseFsSnapshot, "use-fs-snapshot", false, "use filesystem snapshot where possible (currently only Windows VSS)")
|
||||
f.BoolVar(&backupOptions.ExcludeCloudFiles, "exclude-cloud-files", false, "excludes online-only cloud files (such as OneDrive Files On-Demand)")
|
||||
}
|
||||
f.BoolVar(&backupOptions.SkipIfUnchanged, "skip-if-unchanged", false, "skip snapshot creation if identical to parent snapshot")
|
||||
|
||||
@@ -347,6 +349,17 @@ func collectRejectFuncs(opts BackupOptions, targets []string, fs fs.FS) (funcs [
|
||||
funcs = append(funcs, f)
|
||||
}
|
||||
|
||||
if opts.ExcludeCloudFiles && !opts.Stdin && !opts.StdinCommand {
|
||||
if runtime.GOOS != "windows" {
|
||||
return nil, errors.Fatalf("exclude-cloud-files is only supported on Windows")
|
||||
}
|
||||
f, err := archiver.RejectCloudFiles(Warnf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
funcs = append(funcs, f)
|
||||
}
|
||||
|
||||
if opts.ExcludeCaches {
|
||||
opts.ExcludeIfPresent = append(opts.ExcludeIfPresent, "CACHEDIR.TAG:Signature: 8a477f597d28d172789f06886806bc55")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user