forked from TrueCloudLab/restic
Merge pull request #5039 from konidev20/fix-gh-4806-forget-add-reason-for-oldest-snapshot-retained
forget: indicate why the oldest snapshot in a group is kept
This commit is contained in:
commit
7b1a15916d
6 changed files with 13 additions and 6 deletions
|
@ -214,7 +214,8 @@ The ``forget`` command accepts the following policy options:
|
|||
run) and these snapshots will hence not be removed.
|
||||
|
||||
.. note:: If there are not enough snapshots to keep one for each duration related
|
||||
``--keep-{within-,}*`` option, the oldest snapshot is kept additionally.
|
||||
``--keep-{within-,}*`` option, the oldest snapshot is kept additionally and
|
||||
marked as ``oldest`` in the output (e.g. ``oldest hourly snapshot``).
|
||||
|
||||
.. note:: Specifying ``--keep-tag ''`` will match untagged snapshots only.
|
||||
|
||||
|
|
|
@ -256,6 +256,9 @@ func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reason
|
|||
if val != b.Last || nr == len(list)-1 {
|
||||
debug.Log("keep %v %v, bucker %v, val %v\n", cur.Time, cur.id.Str(), i, val)
|
||||
keepSnap = true
|
||||
if val == b.Last && nr == len(list)-1 {
|
||||
b.reason = fmt.Sprintf("oldest %v", b.reason)
|
||||
}
|
||||
buckets[i].Last = val
|
||||
if buckets[i].Count > 0 {
|
||||
buckets[i].Count--
|
||||
|
@ -275,6 +278,9 @@ func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reason
|
|||
if val != b.Last || nr == len(list)-1 {
|
||||
debug.Log("keep %v, time %v, ID %v, bucker %v, val %v %v\n", b.reason, cur.Time, cur.id.Str(), i, val, b.Last)
|
||||
keepSnap = true
|
||||
if val == b.Last && nr == len(list)-1 {
|
||||
b.reason = fmt.Sprintf("oldest %v", b.reason)
|
||||
}
|
||||
bucketsWithin[i].Last = val
|
||||
keepSnapReasons = append(keepSnapReasons, fmt.Sprintf("%v %v", b.reason, b.Within))
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"yearly snapshot"
|
||||
"oldest yearly snapshot"
|
||||
],
|
||||
"counters": {
|
||||
"yearly": 6
|
||||
|
|
|
@ -214,7 +214,7 @@
|
|||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"yearly snapshot"
|
||||
"oldest yearly snapshot"
|
||||
],
|
||||
"counters": {
|
||||
"yearly": 6
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"yearly within 9999y"
|
||||
"oldest yearly within 9999y"
|
||||
],
|
||||
"counters": {}
|
||||
}
|
||||
|
|
|
@ -238,8 +238,8 @@
|
|||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"monthly snapshot",
|
||||
"yearly snapshot"
|
||||
"oldest monthly snapshot",
|
||||
"oldest yearly snapshot"
|
||||
],
|
||||
"counters": {
|
||||
"monthly": -1,
|
||||
|
|
Loading…
Reference in a new issue