amazon-s3backupretention

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


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.


Solution

  • By default restic groups your snapshots by host,paths to apply forget policy to each group independently. All your snapshots have different paths, so forget policy applies to each of them separately, leaving alive at least 1 latest snapshot in the each group. You can change this specifying "--group-by host", so all your snapshots will be considereder together. But you should understand the consequences.