Retention Policy

Hello, Everyone!

The issue: restic retains only 3 recent backups.

My backup configs:

  1. Restic data backup is executed each day by cron.
  2. After the backup is finished, retention policy is used:
    restic forget -q --keep-daily 3 --keep-weekly 4 --keep-monthly 3 --keep-yearly 1 --prune

Desired retention:
I need 3 recent daily backups, 4 backups from the last month, 3 backups for the latest 3 months and 1 yearly backup.
The question is: how you configured retention that’s similar to the one above?

I’ve already read all retention topics and found no reliable solution that can be applied to hundreds of servers with different requirements for backups.
Advises are appreciated very much!

I’m guessing that since you always tell restic to only keep three daily backups and always run it every day, it never reaches the point where there’s more than three daily snapshots kept. Does that make sense? If you are unsure, please show us the complete output of the snapshots command.

1 Like

Thanks for your reply!

Yes, you’re right, and I understand what’s happening too.
The issue, that I can’t find a reliable way to configure retention policy.
I do need to clear unnecessary backups each day, since the storage is a limited resource.

Hmm, are you sure? Please note that a snapshot itself only takes up a few kB of disk space. And with each backup you make, theres not much metadata added, besides the actual data that you back up, and the latter here only adds the parts of the backed up files that were added or changed since your last backup.

Have you actually investigated how much is added with each snapshot? The output of the backup command will tell you. I’m thinking that if you don’t have enough disk space to keep much more than a few days worth of backups, then that’s a problem which needs solving before you start looking at retention policies.

1 Like

Specifically, these backups are not for static files, rather they are dynamically changed.
Each day around 5-15% of files are changed, each backup ±40GB.

Guys, if anyone configured successfully backups with retention policy like described above:

3 backups for recent days, 4 backups for last 4 weeks, 3 backups for last 3 months and 1 yearly backup.

I guess, if I change from 3 daily backups to 7 daily other retention rules might work, but still it is +4 extra unwanted copies and there are many cases when it will 100% won’t work, due to huge backup sizes.

Any advises? Thanks in advance!

The --keep-weekly policy will start to retain additional snapshots once the repository contains snapshots from two different weeks. Restic will always keep the latest snapshot per day/week/etc.

The behavior you’re probably expecting is to keep the oldest snapshot until there are enough weekly snapshots? That suggestion is currently tracked in restic forget: Keep also oldest snapshot when there are not enough backups to keep · Issue #3624 · restic/restic · GitHub .

The --keep-yearly 1 policy has no effect. As long as at least a snapshot exists in a repository, then the repository will contain one yearly snapshot. If you want to keep a snapshot from last year too, then you have to keep two yearly snapshots.