Restic forget not removing snapshots correctly


I have the following scenario - backup of a mysql db done every hour and pushed to s3 bucket using resting.

restic snaphots give the following output:

ID        Time                 Host                      Tags        Paths
7c867cf8  2022-12-13 17:02:37  host  mysql       /repo/mysql-backup/db_backup_20221213160546.tgz.enc
ec36199a  2022-12-14 08:00:01  host  mysql       /repo/mysql-backup/db_backup_20221214070546.tgz.enc
b1754878  2022-12-14 09:00:01  host  mysql       /repo/mysql-backup/db_backup_20221214080546.tgz.enc
13d0ce6c  2022-12-14 10:00:02  host  mysql       /repo/mysql-backup/db_backup_20221214090546.tgz.enc

If i run the following command:

restic forget --dry-run --tag=mysql -l 2 which should → --keep-last n keep the n last (most recent) snapshots.

It doesn’t keep just the last 2 snapshots but it keeps everything.

Am i doing something wrong?
Restic version → restic 0.14.0 compiled with go1.19 on linux/amd64
My scenario is the following, i want to keep the last hourly backups from the last 30 days.

Looking forward for some help.
Have a good day,

You should use --group-by tags

1 Like

If you group by host and path, which is the default, and all snapshots have different paths, each snapshot is in its own group and you tell restic to keep the two latest snapshots per group.


Now it worked! thank you very much, @alexweiss!