2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-26 06:46:34 +00:00

forget: Run prune for manually forgotten snapshots

This commit is contained in:
Alexander Neumann 2017-10-03 11:56:13 +02:00
parent abe6e0d22d
commit 034b0b8040

View File

@ -116,6 +116,8 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
} }
} }
removeSnapshots := 0
ctx, cancel := context.WithCancel(gopts.ctx) ctx, cancel := context.WithCancel(gopts.ctx)
defer cancel() defer cancel()
for sn := range FindFilteredSnapshots(ctx, repo, opts.Host, opts.Tags, opts.Paths, args) { for sn := range FindFilteredSnapshots(ctx, repo, opts.Host, opts.Tags, opts.Paths, args) {
@ -127,6 +129,7 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
return err return err
} }
Verbosef("removed snapshot %v\n", sn.ID().Str()) Verbosef("removed snapshot %v\n", sn.ID().Str())
removeSnapshots++
} else { } else {
Verbosef("would have removed snapshot %v\n", sn.ID().Str()) Verbosef("would have removed snapshot %v\n", sn.ID().Str())
} }
@ -178,7 +181,6 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
return nil return nil
} }
removeSnapshots := 0
for k, snapshotGroup := range snapshotGroups { for k, snapshotGroup := range snapshotGroups {
var key key var key key
if json.Unmarshal([]byte(k), &key) != nil { if json.Unmarshal([]byte(k), &key) != nil {