mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 23:06:32 +00:00
cleanup include / exclude option setup
This commit is contained in:
parent
41c031a19e
commit
5d58945718
@ -108,7 +108,7 @@ func init() {
|
||||
f.VarP(&backupOptions.GroupBy, "group-by", "g", "`group` snapshots by host, paths and/or tags, separated by comma (disable grouping with '')")
|
||||
f.BoolVarP(&backupOptions.Force, "force", "f", false, `force re-reading the source files/directories (overrides the "parent" flag)`)
|
||||
|
||||
initExcludePatternOptions(f, &backupOptions.excludePatternOptions)
|
||||
backupOptions.excludePatternOptions.Add(f)
|
||||
|
||||
f.BoolVarP(&backupOptions.ExcludeOtherFS, "one-file-system", "x", false, "exclude other file systems, don't cross filesystem boundaries and subvolumes")
|
||||
f.StringArrayVar(&backupOptions.ExcludeIfPresent, "exclude-if-present", nil, "takes `filename[:header]`, exclude contents of directories containing filename (except filename itself) if header of that file is as provided (can be specified multiple times)")
|
||||
|
@ -68,8 +68,8 @@ func init() {
|
||||
flags := cmdRestore.Flags()
|
||||
flags.StringVarP(&restoreOptions.Target, "target", "t", "", "directory to extract data to")
|
||||
|
||||
initExcludePatternOptions(flags, &restoreOptions.excludePatternOptions)
|
||||
initIncludePatternOptions(flags, &restoreOptions.includePatternOptions)
|
||||
restoreOptions.excludePatternOptions.Add(flags)
|
||||
restoreOptions.includePatternOptions.Add(flags)
|
||||
|
||||
initSingleSnapshotFilter(flags, &restoreOptions.SnapshotFilter)
|
||||
flags.BoolVar(&restoreOptions.DryRun, "dry-run", false, "do not write any data, just show what would be done")
|
||||
|
@ -103,7 +103,7 @@ func init() {
|
||||
f.StringVar(&rewriteOptions.Metadata.Time, "new-time", "", "replace time of the backup")
|
||||
|
||||
initMultiSnapshotFilter(f, &rewriteOptions.SnapshotFilter, true)
|
||||
initExcludePatternOptions(f, &rewriteOptions.excludePatternOptions)
|
||||
rewriteOptions.excludePatternOptions.Add(f)
|
||||
}
|
||||
|
||||
type rewriteFilterFunc func(ctx context.Context, sn *restic.Snapshot) (restic.ID, error)
|
||||
|
@ -130,7 +130,7 @@ type excludePatternOptions struct {
|
||||
InsensitiveExcludeFiles []string
|
||||
}
|
||||
|
||||
func initExcludePatternOptions(f *pflag.FlagSet, opts *excludePatternOptions) {
|
||||
func (opts *excludePatternOptions) Add(f *pflag.FlagSet) {
|
||||
f.StringArrayVarP(&opts.Excludes, "exclude", "e", nil, "exclude a `pattern` (can be specified multiple times)")
|
||||
f.StringArrayVar(&opts.InsensitiveExcludes, "iexclude", nil, "same as --exclude `pattern` but ignores the casing of filenames")
|
||||
f.StringArrayVar(&opts.ExcludeFiles, "exclude-file", nil, "read exclude patterns from a `file` (can be specified multiple times)")
|
||||
|
@ -19,7 +19,7 @@ type includePatternOptions struct {
|
||||
InsensitiveIncludeFiles []string
|
||||
}
|
||||
|
||||
func initIncludePatternOptions(f *pflag.FlagSet, opts *includePatternOptions) {
|
||||
func (opts *includePatternOptions) Add(f *pflag.FlagSet) {
|
||||
f.StringArrayVarP(&opts.Includes, "include", "i", nil, "include a `pattern` (can be specified multiple times)")
|
||||
f.StringArrayVar(&opts.InsensitiveIncludes, "iinclude", nil, "same as --include `pattern` but ignores the casing of filenames")
|
||||
f.StringArrayVar(&opts.IncludeFiles, "include-file", nil, "read include patterns from a `file` (can be specified multiple times)")
|
||||
|
Loading…
Reference in New Issue
Block a user