From 5f0ebb71b2fc9524b58b08efca488ae5f8ffbb66 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 20 Aug 2016 17:59:47 +0200 Subject: [PATCH] forget: Allow filtering for a hostname --- src/cmds/restic/cmd_forget.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmds/restic/cmd_forget.go b/src/cmds/restic/cmd_forget.go index 079433164..dd43c1fc4 100644 --- a/src/cmds/restic/cmd_forget.go +++ b/src/cmds/restic/cmd_forget.go @@ -17,6 +17,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"` + DryRun bool `short:"n" long:"dry-run" description:"do not delete anything, just print what would be done"` global *GlobalOptions @@ -125,6 +127,10 @@ func (cmd CmdForget) Execute(args []string) error { snapshotGroups := make(map[key]restic.Snapshots) for _, sn := range snapshots { + if cmd.Hostname != "" && sn.Hostname != cmd.Hostname { + continue + } + k := key{Hostname: sn.Hostname, Dirs: strings.Join(sn.Paths, ":")} list := snapshotGroups[k] list = append(list, sn)