When I run restic forget, the reasons column shows why a given snapshot is kept (and not forgotten/removed). Why is there more than one snapshot with the reason “yearly snapshot”?
My understanding was that as the snapshot e06f9ced from November 2021 is the last of 2021. So the snapshot 3d2f2da4 from October 2021 is not needed as a yearly snapshot. Why does restic decide differently?
Is the year counted as calendar year or from today one year back in time (2022-12-10 to 2023-12-10)? In the latter case the output makes sense. I just always thought in calendar years (same for days, weeks and months).
Hm, the docs say it’s the “natural time boundaries”, so I also don’t understand why two items are kept because of “yearly snapshot”.
All calendar related options (--keep-{hourly,daily,...}) work on natural time boundaries and not relative to when you run forget. Weeks are Monday 00:00 to Sunday 23:59, days 00:00 to 23:59, hours :00 to :59, etc. They also only count hours/days/weeks/etc which have one or more snapshots. A value of -1 will be interpreted as “forever”, i.e. “keep all”.
Looking into the code would tell how it’s actually computed.
// also keep the oldest snapshot if the bucket has some counts left. This maximizes the
// the history length kept while some counts are left.
if val != b.Last || nr == len(list)-1 {
I could not find any hint in the documentation, though.
I think this is related to the fact that there are not enough yearly snapshots to fulfill your request (keep 9 yearly snapshots). Hence the oldest snapshot is also chosen as “yearly” one. The same would apply to monthly etc.
IIRC the behavior was different (and the way you expected it) some months ago, but there was a feature request to add this functionality.
In case you haven’t: If the docs are missing something, please raise an issue or open a PR to fix it
Since you already checked out the code, I thought I’d at least ask you