Keep assistance

Apologies but my brain isn’t braining with Removing backup snapshots — restic 0.14.0 documentation

I have a folder being backed up every hour for 14 days. I want to keep all 14 hourly backups which = 336 snapshots.

I’d like to keep 1 from each week dating back 2 months which = 8 snapshots.

I’d like to keep 1 from each month dating back 12 months which = 12 snapshots.

What’s the forget/prune command to do this please?

Assuming this folder is the only path being backed up to the restic repository in question, I believe this should do what you want:

restic forget --keep-hourly 336 --keep-weekly 8 --keep-monthly 12

add --prune if you want to forget + prune in one command, and I’d recommend you test the forget policy with --dry-run as well before committing to it.

Wouldn’t the “within” keep options be useful? E.g. --keep-within-hourly 14d --keep-within-weekly 1m --keep-within-monthly 1y.

Please run that but with the --dry-run flag so that you can determine whether or not the policy is working as intended. I’m not sure if you need to increment each of the options by one (e.g. 15d instead of 14d, and so on), I know you need to do that with the non-within options. But the dry-run should let you know, as long as you have enough snapshots for the last 15 or more days to verify.