mirror of
https://github.com/restic/restic.git
synced 2025-03-16 00:00:05 +01:00
Add CLI flag to enable excluding from gitignore
This commit is contained in:
parent
b175308b66
commit
be5c7f6605
1 changed files with 10 additions and 0 deletions
|
@ -95,6 +95,7 @@ type BackupOptions struct {
|
|||
ExcludeIfPresent []string
|
||||
ExcludeCaches bool
|
||||
ExcludeLargerThan string
|
||||
ExcludeGitignored bool
|
||||
Stdin bool
|
||||
StdinFilename string
|
||||
Tags restic.TagLists
|
||||
|
@ -132,6 +133,7 @@ func init() {
|
|||
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)")
|
||||
f.BoolVar(&backupOptions.ExcludeCaches, "exclude-caches", false, `excludes cache directories that are marked with a CACHEDIR.TAG file. See https://bford.info/cachedir/ for the Cache Directory Tagging Standard`)
|
||||
f.StringVar(&backupOptions.ExcludeLargerThan, "exclude-larger-than", "", "max `size` of the files to be backed up (allowed suffixes: k/K, m/M, g/G, t/T)")
|
||||
f.BoolVar(&backupOptions.ExcludeGitignored, "exclude-gitignored", false, "excludes from the backup any file or directory which is ignored through a `.gitignore`. Files and directories which are specified directly (through file args, `files-from` or `files-from-x` arguments) are always included.")
|
||||
f.BoolVar(&backupOptions.Stdin, "stdin", false, "read backup from stdin")
|
||||
f.StringVar(&backupOptions.StdinFilename, "stdin-filename", "stdin", "`filename` to use when reading from stdin")
|
||||
f.Var(&backupOptions.Tags, "tag", "add `tags` for the new snapshot in the format `tag[,tag,...]` (can be specified multiple times)")
|
||||
|
@ -338,6 +340,14 @@ func collectRejectByNameFuncs(opts BackupOptions, repo *repository.Repository, t
|
|||
fs = append(fs, f)
|
||||
}
|
||||
|
||||
if opts.ExcludeGitignored {
|
||||
f, err := rejectGitignored(targets)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fs = append(fs, f)
|
||||
}
|
||||
|
||||
return fs, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue