How is the retention solved if a smaller time period is less than one unit of the next larger one?

So the blog post on this topic and the documentation are pretty good but I still have problems to understand the following case:

How will rclone decide if I have two rules (i.e. --keep-daily and --keep-weekly) and the “smaller” unit (in this case daily) is less than the next higher unit (weekly).

So for example: keep three daily backups and three weekly.
Which of those daily backups will become the one for the week?

The documentation says only keep the last one for that ….
So does that mean that sundays backup will be kept in this case?

So that means if I start new, I would have backups from four following days (sunday for the weekly and monday, tuesday and wednesday from the daily) on next wednesday?

The easiest way to see how restic behaves would be to run forget --dry-run .... restic will then print a list with all snapshots along with the reason due to which policy a snapshot is kept.

In your first example restic will keep enough backups to have three backups that count as daily backups along with three backups that count as weekly. One snapshot can both serve as daily and weekly snapshot at the same time.

With backups on Sunday (Week 1) and Monday, Tuesday and Wednesday (Week 2) restic would keep all of them:

sunday        weekly
monday        daily
tuesday       daily
wednesday     weekly, daily

Therefore with up to three daily and weekly snapshots all four snapshots would be kept. Adding a further backup on Thursday changes things a bit:

kept:
sunday        weekly
tuesday       daily
wednesday     daily
thursday      weekly, daily

removed:
monday

The backup from Monday gets removed as only up to 3 daily snapshots are kept and as that snapshot is also no weekly snapshot. Also note that the weekly label has moved to Thursday as it is the last snapshot in Week 2.

Thank you for your response.

In theory it would. But I didn’t have four backups yet in this case.

For testing you could run backup --time <timestamp> to create a few test backups.

1 Like

Nice, I didn’t know that!

That’s brilliant! Thanks for the idea. :upside_down_face: