2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-15 17:47:21 +00:00

Merge pull request #242 from restic/add-exclude-patterns-to-snapshot

Record exclude patterns in snapshot
This commit is contained in:
Alexander Neumann 2015-07-23 20:11:43 +02:00
commit b5ebd702fe
4 changed files with 9 additions and 5 deletions

View File

@ -36,6 +36,7 @@ type Archiver struct {
Error func(dir string, fi os.FileInfo, err error) error
SelectFilter pipe.SelectFunc
Excludes []string
}
// NewArchiver returns a new archiver.
@ -549,6 +550,7 @@ func (arch *Archiver) Snapshot(p *Progress, paths []string, parentID backend.ID)
if err != nil {
return nil, nil, err
}
sn.Excludes = arch.Excludes
jobs := archivePipe{}

View File

@ -16,9 +16,9 @@ import (
)
type CmdBackup struct {
Parent string `short:"p" long:"parent" description:"use this parent snapshot (default: last snapshot in repo that has the same target)"`
Force bool `short:"f" long:"force" description:"Force re-reading the target. Overrides the \"parent\" flag"`
Exclude []string `short:"e" long:"exclude" description:"Exclude a pattern (can be specified multiple times)"`
Parent string `short:"p" long:"parent" description:"use this parent snapshot (default: last snapshot in repo that has the same target)"`
Force bool `short:"f" long:"force" description:"Force re-reading the target. Overrides the \"parent\" flag"`
Excludes []string `short:"e" long:"exclude" description:"Exclude a pattern (can be specified multiple times)"`
global *GlobalOptions
}
@ -285,7 +285,7 @@ func (cmd CmdBackup) Execute(args []string) error {
cmd.global.Verbosef("scan %v\n", target)
selectFilter := func(item string, fi os.FileInfo) bool {
matched, err := filter.List(cmd.Exclude, item)
matched, err := filter.List(cmd.Excludes, item)
if err != nil {
cmd.global.Warnf("error for exclude pattern: %v", err)
}
@ -299,6 +299,7 @@ func (cmd CmdBackup) Execute(args []string) error {
}
arch := restic.NewArchiver(repo)
arch.Excludes = cmd.Excludes
arch.SelectFilter = selectFilter
arch.Error = func(dir string, fi os.FileInfo, err error) error {

View File

@ -50,7 +50,7 @@ func cmdBackup(t testing.TB, global GlobalOptions, target []string, parentID bac
}
func cmdBackupExcludes(t testing.TB, global GlobalOptions, target []string, parentID backend.ID, excludes []string) {
cmd := &CmdBackup{global: &global, Exclude: excludes}
cmd := &CmdBackup{global: &global, Excludes: excludes}
cmd.Parent = parentID.String()
t.Logf("backing up %v", target)

View File

@ -21,6 +21,7 @@ type Snapshot struct {
Username string `json:"username,omitempty"`
UID uint32 `json:"uid,omitempty"`
GID uint32 `json:"gid,omitempty"`
Excludes []string `json:"excludes,omitempty"`
id backend.ID // plaintext ID, used during restore
}