mirror of
https://github.com/restic/restic.git
synced 2025-08-23 14:57:37 +00:00
Issue #3624: Preserve oldest snapshot when keep-* values are not satisfied
This commit is contained in:

committed by
Michael Eischer

parent
4df77e9f26
commit
182b9796e4
@@ -256,7 +256,7 @@ func ApplyPolicy(list Snapshots, p ExpirePolicy) (keep, remove Snapshots, reason
|
||||
// -1 means "keep all"
|
||||
if b.Count > 0 || b.Count == -1 {
|
||||
val := b.bucker(cur.Time, nr)
|
||||
if val != b.Last {
|
||||
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
|
||||
buckets[i].Last = val
|
||||
|
@@ -14,6 +14,11 @@
|
||||
"time": "2014-11-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2014-08-08T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
}
|
||||
],
|
||||
"reasons": [
|
||||
@@ -55,6 +60,19 @@
|
||||
"counters": {
|
||||
"yearly": 7
|
||||
}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2014-08-08T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"yearly snapshot"
|
||||
],
|
||||
"counters": {
|
||||
"yearly": 6
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@@ -49,6 +49,11 @@
|
||||
"time": "2014-11-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2014-08-08T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
}
|
||||
],
|
||||
"reasons": [
|
||||
@@ -201,6 +206,19 @@
|
||||
"counters": {
|
||||
"yearly": 7
|
||||
}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2014-08-08T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"yearly snapshot"
|
||||
],
|
||||
"counters": {
|
||||
"yearly": 6
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@@ -57,6 +57,11 @@
|
||||
"time": "2014-08-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2014-08-08T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
}
|
||||
],
|
||||
"reasons": [
|
||||
@@ -189,6 +194,18 @@
|
||||
"monthly snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2014-08-08T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"monthly snapshot",
|
||||
"yearly snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user