2
2
mirror of https://github.com/octoleo/restic.git synced 2024-05-31 08:00:48 +00:00

forget: Also run prune when only IDs are forgotten

This commit is contained in:
Alexander Neumann 2018-01-01 21:27:40 +01:00
parent 559946c58a
commit c912b38bf0

View File

@ -162,9 +162,6 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
snapshotGroups[string(k)] = append(snapshotGroups[string(k)], sn)
}
}
if len(args) > 0 {
return nil
}
policy := restic.ExpirePolicy{
Last: opts.Last,
@ -176,11 +173,11 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
Tags: opts.KeepTags,
}
if policy.Empty() {
if policy.Empty() && len(args) == 0 {
Verbosef("no policy was specified, no snapshots will be removed\n")
return nil
}
if !policy.Empty() {
for k, snapshotGroup := range snapshotGroups {
var key key
if json.Unmarshal([]byte(k), &key) != nil {
@ -230,6 +227,7 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
}
}
}
}
if removeSnapshots > 0 && opts.Prune {
Verbosef("%d snapshots have been removed, running prune\n", removeSnapshots)