mirror of
https://github.com/restic/restic.git
synced 2025-12-15 21:11:59 +00:00
forget: Add --unsafe-allow-remove-all option
To prevent accidentally wiping all snapshots from a repository, that option can only be used if either a snapshot filter or a keep policy is specified. Essentially, the option allows `forget --tag something --unsafe-allow-remove-all` calls to remove all snapshots with a specific tag.
This commit is contained in:
@@ -94,7 +94,11 @@ func (e ExpirePolicy) String() (s string) {
|
||||
s += fmt.Sprintf("all snapshots within %s of the newest", e.Within)
|
||||
}
|
||||
|
||||
s = "keep " + s
|
||||
if s == "" {
|
||||
s = "remove"
|
||||
} else {
|
||||
s = "keep " + s
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
@@ -186,16 +190,6 @@ func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reason
|
||||
// sort newest snapshots first
|
||||
sort.Stable(list)
|
||||
|
||||
if p.Empty() {
|
||||
for _, sn := range list {
|
||||
reasons = append(reasons, KeepReason{
|
||||
Snapshot: sn,
|
||||
Matches: []string{"policy is empty"},
|
||||
})
|
||||
}
|
||||
return list, remove, reasons
|
||||
}
|
||||
|
||||
if len(list) == 0 {
|
||||
return list, nil, nil
|
||||
}
|
||||
|
||||
1781
internal/restic/testdata/policy_keep_snapshots_0
vendored
1781
internal/restic/testdata/policy_keep_snapshots_0
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user