From 0f9fb37c788c1bcba11cca9c57eb412542f66b0c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 13 Sep 2016 20:20:55 +0200 Subject: [PATCH] Add tags to forget command --- src/cmds/restic/cmd_forget.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmds/restic/cmd_forget.go b/src/cmds/restic/cmd_forget.go index 3f4ec12c6..1a2e98098 100644 --- a/src/cmds/restic/cmd_forget.go +++ b/src/cmds/restic/cmd_forget.go @@ -16,7 +16,8 @@ type CmdForget struct { Monthly int `short:"m" long:"keep-monthly" description:"keep the last n monthly snapshots"` Yearly int `short:"y" long:"keep-yearly" description:"keep the last n yearly snapshots"` - Hostname string `long:"hostname" description:"only forget snapshots for the given hostname"` + Hostname string `long:"hostname" description:"only forget snapshots for the given hostname"` + Tags []string `long:"tag" description:"only forget snapshots with the tag (can be specified multiple times)"` DryRun bool `short:"n" long:"dry-run" description:"do not delete anything, just print what would be done"` @@ -135,6 +136,10 @@ func (cmd CmdForget) Execute(args []string) error { continue } + if !sn.HasTags(cmd.Tags) { + continue + } + k := key{Hostname: sn.Hostname, Dirs: strings.Join(sn.Paths, ":")} list := snapshotGroups[k] list = append(list, sn)