Confusion about `--keep-daily` option

Hi there,

I’m new to restic and trying to set up a backup with a reasonable retention policy. The end goal is to keep one snapshot for the last 3 months and one snapshot for the last 7 days.

The --keep-daily and --keep-monthly options are similar enough but they don’t seem to work like I understand the docs:

[root@host ~]# restic forget --keep-daily 7 --dry-run
repository 8c3262dd opened (version 2, compression level auto)
Applying Policy: keep 7 daily snapshots
keep 2 snapshots:
ID        Time                 Host                                             Tags        Reasons         Paths
bc4d0e34  2024-06-27 10:31:19  host                                                         daily snapshot  /tmp/backup
51a86351  2024-06-27 10:50:39  host                                                         daily snapshot  /tmp/backup
2 snapshots

Why does it keep both snapshots as daily? They are both from the same day so I would assume restic would delete the older one.

Hi @soster,

I’m pretty sure that’s the same question I once asked about yearly snapshots: Multiple snapshots kept per year

Restic keeps the oldest snapshot as some kind of best effort approach if there are not enough snapshots for your keep rules. Your command requests to keep 7 daily snapshots but there are not enough, so it keeps the oldest snapshot to get a bit closer to the specified 7. Once you have snapshots on 7 or more days, this oldest snapshot will be removed by restic forget.

There is some more information in the link above.

1 Like