forget: Do nothing if no policy is configured
This commit is contained in:
parent
71f7f4f543
commit
5cf7c827b8
1 changed files with 13 additions and 9 deletions
|
@ -94,7 +94,20 @@ func (cmd CmdForget) Execute(args []string) error {
|
|||
} else {
|
||||
cmd.global.Verbosef("would removed snapshot %v\n", id.Str())
|
||||
}
|
||||
}
|
||||
|
||||
policy := restic.ExpirePolicy{
|
||||
Last: cmd.Last,
|
||||
Hourly: cmd.Hourly,
|
||||
Daily: cmd.Daily,
|
||||
Weekly: cmd.Weekly,
|
||||
Monthly: cmd.Monthly,
|
||||
Yearly: cmd.Yearly,
|
||||
}
|
||||
|
||||
if policy.Empty() {
|
||||
cmd.global.Verbosef("no expire policy configured, exiting\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
// then, load all remaining snapshots
|
||||
|
@ -118,15 +131,6 @@ func (cmd CmdForget) Execute(args []string) error {
|
|||
snapshotGroups[k] = list
|
||||
}
|
||||
|
||||
policy := restic.ExpirePolicy{
|
||||
Last: cmd.Last,
|
||||
Hourly: cmd.Hourly,
|
||||
Daily: cmd.Daily,
|
||||
Weekly: cmd.Weekly,
|
||||
Monthly: cmd.Monthly,
|
||||
Yearly: cmd.Yearly,
|
||||
}
|
||||
|
||||
for key, snapshotGroup := range snapshotGroups {
|
||||
cmd.global.Printf("snapshots for host %v, directories %v:\n\n", key.Hostname, key.Dirs)
|
||||
keep, remove := restic.ApplyPolicy(snapshotGroup, policy)
|
||||
|
|
Loading…
Reference in a new issue