mirror of
https://github.com/restic/restic.git
synced 2024-12-21 23:33:03 +00:00
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.
|
run) and these snapshots will hence not be removed.
|
||||||
|
|
||||||
.. note:: If there are not enough snapshots to keep one for each duration related
|
.. 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.
|
.. 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 {
|
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)
|
debug.Log("keep %v %v, bucker %v, val %v\n", cur.Time, cur.id.Str(), i, val)
|
||||||
keepSnap = true
|
keepSnap = true
|
||||||
|
if val == b.Last && nr == len(list)-1 {
|
||||||
|
b.reason = fmt.Sprintf("oldest %v", b.reason)
|
||||||
|
}
|
||||||
buckets[i].Last = val
|
buckets[i].Last = val
|
||||||
if buckets[i].Count > 0 {
|
if buckets[i].Count > 0 {
|
||||||
buckets[i].Count--
|
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 {
|
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)
|
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
|
keepSnap = true
|
||||||
|
if val == b.Last && nr == len(list)-1 {
|
||||||
|
b.reason = fmt.Sprintf("oldest %v", b.reason)
|
||||||
|
}
|
||||||
bucketsWithin[i].Last = val
|
bucketsWithin[i].Last = val
|
||||||
keepSnapReasons = append(keepSnapReasons, fmt.Sprintf("%v %v", b.reason, b.Within))
|
keepSnapReasons = append(keepSnapReasons, fmt.Sprintf("%v %v", b.reason, b.Within))
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
"paths": null
|
"paths": null
|
||||||
},
|
},
|
||||||
"matches": [
|
"matches": [
|
||||||
"yearly snapshot"
|
"oldest yearly snapshot"
|
||||||
],
|
],
|
||||||
"counters": {
|
"counters": {
|
||||||
"yearly": 6
|
"yearly": 6
|
||||||
|
|
|
@ -214,7 +214,7 @@
|
||||||
"paths": null
|
"paths": null
|
||||||
},
|
},
|
||||||
"matches": [
|
"matches": [
|
||||||
"yearly snapshot"
|
"oldest yearly snapshot"
|
||||||
],
|
],
|
||||||
"counters": {
|
"counters": {
|
||||||
"yearly": 6
|
"yearly": 6
|
||||||
|
|
|
@ -165,7 +165,7 @@
|
||||||
"paths": null
|
"paths": null
|
||||||
},
|
},
|
||||||
"matches": [
|
"matches": [
|
||||||
"yearly within 9999y"
|
"oldest yearly within 9999y"
|
||||||
],
|
],
|
||||||
"counters": {}
|
"counters": {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,8 +238,8 @@
|
||||||
"paths": null
|
"paths": null
|
||||||
},
|
},
|
||||||
"matches": [
|
"matches": [
|
||||||
"monthly snapshot",
|
"oldest monthly snapshot",
|
||||||
"yearly snapshot"
|
"oldest yearly snapshot"
|
||||||
],
|
],
|
||||||
"counters": {
|
"counters": {
|
||||||
"monthly": -1,
|
"monthly": -1,
|
||||||
|
|
Loading…
Reference in a new issue