--keep-last 1 does not delete previous snapshots

I’m sure I’m just interpreting this wrong.

I’m currently testing Restic, trying and experimenting on a test server, before this is put in production.

Backups seem to be working very well, but as storage is expensive, I want to ensure older data is expired as soon as possible, and not kept forever.

In this experiment, I’m trying to delete ALL snapshots except the last.
I’m assuming that the last snapshot will contain the “state” of the last time I ran the backup.

So, after creating 3 snapshots, I ran:

# source /opt/restic/.restic.env ; /usr/local/bin/restic forget --keep-last 1 --prune

However, none of the 3 snapshots were deleted, with the following reasons:

repository abcdabcd opened successfully, password is correct
Applying Policy: keep the last 1 snapshots snapshots
keep 1 snapshots:
ID        Time                 Host                Tags        Reasons        Paths
--------------------------------------------------------------------------------------------
abcd1234  2019-12-20 22:35:00  server.host.com     daily       last snapshot  /...
--------------------------------------------------------------------------------------------
1 snapshots

keep 1 snapshots:
ID        Time                 Host                Tags        Reasons        Paths
--------------------------------------------------------------------------------------------
efgh5678  2019-12-20 22:59:15  server.host.com     daily       last snapshot  /...
--------------------------------------------------------------------------------------------
1 snapshots

keep 1 snapshots:
ID        Time                 Host                Tags        Reasons        Paths
--------------------------------------------------------------------------------------------
ijkl9101  2019-12-20 23:23:32  server.host.com     daily       last snapshot  /...
--------------------------------------------------------------------------------------------
1 snapshots

Is anyone able to explain me why?
I was expecting only the latest snapshot to stay.

Thank you very much.

It’s probably due to the grouping. But since you obfuscated the snapshots output it’s hard to tell. Please edit your post so it contains the unedited output from the snapshots command, then we’ll see!

Or if you want to investigate it yourself, see the --group-by argument to the forget command.

1 Like

Aaah!! That does make sense. The Paths were indeed different, since I was trying different versions of “file includes”.
That’s no problem, then. At least I understand the reason.
Thank you very much.