Restic retention policy --keep-within 1m does not work

20 views Asked by At

My rentention policy is the following:

restic -r $RESTIC_REPOSITORY forget --keep-within 1m --prune

yet, the output of restic snapshots is the following:

Applying Policy: keep all snapshots within 1m of the newest
keep 1 snapshots:
ID        Time                 Host        Tags        Reasons    Paths
----------------------------------------------------------------------------------------------
458d9d2a  2024-01-27 17:13:23  host                  within 1m  /home/.snapshots/11
----------------------------------------------------------------------------------------------
1 snapshots

keep 1 snapshots:
ID        Time                 Host        Tags        Reasons    Paths
-----------------------------------------------------------------------------------------------
7b671e1c  2024-03-08 12:35:55  host                  within 1m  /home/.snapshots/346
-----------------------------------------------------------------------------------------------
1 snapshots

keep 1 snapshots:
ID        Time                 Host        Tags        Reasons    Paths
-----------------------------------------------------------------------------------------------
49d182c7  2024-02-29 19:26:01  host                  within 1m  /home/.snapshots/281
-----------------------------------------------------------------------------------------------
1 snapshots

keep 1 snapshots:
ID        Time                 Host        Tags        Reasons    Paths
-----------------------------------------------------------------------------------------------
def595d3  2024-02-25 12:21:34  host                  within 1m  /home/.snapshots/225
-----------------------------------------------------------------------------------------------
1 snapshots

keep 1 snapshots:
ID        Time                 Host        Tags        Reasons    Paths
----------------------------------------------------------------------------------------------
56972a3a  2024-01-31 20:16:16  host                  within 1m  /home/.snapshots/49
----------------------------------------------------------------------------------------------
1 snapshots

keep 1 snapshots:
ID        Time                 Host        Tags        Reasons    Paths
-----------------------------------------------------------------------------------------------
5b3b4ec5  2024-02-09 12:00:01  host                  within 1m  /home/.snapshots/100
-----------------------------------------------------------------------------------------------
1 snapshots

And we are march 8th 2024. Clearly, snapshot 458d9d2a should be deleted. Yet it keeps it with the reason that it is within 1m.

I read the doc, it should be working, so I don’t get it.

1

There are 1 answers

1
Tack Support On

If those are all snapshots from different hosts, then according to the documentation then

If there are not enough snapshots to keep one for each duration related --keep-{within-,}* option, the oldest snapshot is kept additionally.

and

For safety reasons, restic refuses to act on an “empty” policy. For example, if one were to specify --keep-last 0 to forget all snapshots in the repository, restic will respond that no snapshots will be removed. To delete all snapshots, use --keep-last 1 and then finally remove the last snapshot manually (by passing the ID to forget).

While neither of these exactly apply to your situation, my guess would be that restic is not deleting the last snapshot from a host for safety reasons and you would need to delete those manually with a restic -r /srv/restic-repo forget 458d9d2a