Why would my snapshot not be deleted when it is more than 2 years old?

I am using autorestic, but here is the forget policy I have

keep-weekly: 1
keep-monthly: 3

Here is the output of my snapshots

> Executing: /usr/local/bin/restic snapshots --tag ar:location:array
ID        Time                 Host        Tags               Paths                      Size
--------------------------------------------------------------------------------------------------
92bc5ea8  2022-12-31 02:33:37  EDITH       ar:location:array  /mnt/user/backup
                                                              /mnt/user/backups-appdata
                                                              /mnt/user/backups-other
                                                              /mnt/user/domains
                                                              /mnt/user/downloads
                                                              /mnt/user/familia
                                                              /mnt/user/isos
                                                              /mnt/user/media
                                                              /mnt/user/media-ripping
                                                              /mnt/user/stash


                                                              /mnt/user/isos
                                                              /mnt/user/media
                                                              /mnt/user/media-ripping
                                                              /mnt/user/stash

89130e23  2024-06-30 02:39:50  EDITH       ar:location:array  /mnt/user/backup
                                                              /mnt/user/backups-other
                                                              /mnt/user/domains
                                                              /mnt/user/downloads
                                                              /mnt/user/familia
                                                              /mnt/user/isos
                                                              /mnt/user/media
                                                              /mnt/user/media-ripping
                                                              /mnt/user/stash

52f4a058  2024-07-23 02:43:35  EDITH       ar:location:array  /mnt/user/backup
                                                              /mnt/user/backups-other
                                                              /mnt/user/domains
                                                              /mnt/user/downloads
                                                              /mnt/user/familia
                                                              /mnt/user/isos
                                                              /mnt/user/media
                                                              /mnt/user/media-ripping
                                                              /mnt/user/stash

858ecc83  2024-08-16 02:44:24  EDITH       ar:location:array  /mnt/user/backup           7.602 TiB
                                                              /mnt/user/backups-other
                                                              /mnt/user/domains
                                                              /mnt/user/downloads
                                                              /mnt/user/familia
                                                              /mnt/user/isos
                                                              /mnt/user/media
                                                              /mnt/user/media-ripping
                                                              /mnt/user/stash
--------------------------------------------------------------------------------------------------

As far as I understand my policy would keep only 3 total snapshots since the keep-weekly: 1 keeps 1 of the keep-monthly: 3 for the month and then only 2 more would be kept correct?

By default, forget policies are grouped by host,path (see restic forget --help), and you have two different path groups. Notice that /mnt/user/backups-appdata is only on the oldest snapshot. If you want to forget this old snapshot, you should use restic forget --group-by host.

You can always use --dry-run to see how different policies work for you. Check the Reasons column to see which policy is applied to each snapshot.

3 Likes

Hi so I ran restic forget --keep-daily 14 --prune --group-by host --verbose

I previously had this many snapshots

ID        Time                 Host        Tags                   Paths                Size
--------------------------------------------------------------------------------------------------
c0611b3a  2024-06-30 02:20:08  EDITH       ar:location:important  /boot
                                                                  /mnt/user/appdata
                                                                  /mnt/user/nextcloud
                                                                  /mnt/user/storage

6785eae3  2024-07-21 02:19:29  EDITH       ar:location:important  /boot
                                                                  /mnt/user/appdata
                                                                  /mnt/user/nextcloud
                                                                  /mnt/user/storage

bcedf62a  2024-07-23 02:19:48  EDITH       ar:location:important  /boot
                                                                  /mnt/user/appdata
                                                                  /mnt/user/nextcloud
                                                                  /mnt/user/storage

65571e1a  2024-08-11 02:34:13  EDITH       ar:location:important  /boot                1.186 TiB
                                                                  /mnt/user/appdata
                                                                  /mnt/user/nextcloud
                                                                  /mnt/user/storage

6d91a402  2024-08-16 02:19:52  EDITH       ar:location:important  /boot                1.190 TiB
                                                                  /mnt/user/appdata
                                                                  /mnt/user/nextcloud
                                                                  /mnt/user/storage

981cc9cc  2024-08-20 11:35:35  EDITH                              /mnt/user/nextcloud  929.148 GiB
                                                                  /mnt/user/storage

6c7e399c  2024-08-20 11:44:57  EDITH       ar:location:important  /mnt/user/nextcloud  929.148 GiB
                                                                  /mnt/user/storage

11c69ed7  2024-08-20 11:53:05  EDITH       ar:location:important  /mnt/user/nextcloud  929.148 GiB
                                                                  /mnt/user/storage
--------------------------------------------------------------------------------------------------

I am transitioning to lower the amount of storage on my cloud provider to lower cost as I now have more storage on a remote server I manage. I changed the path and expected for all these snaphost to be removed. However, after running the command up top i get:

Applying Policy: keep 14 daily snapshots
snapshots for (host [EDITH]):
keep 6 snapshots:
ID        Time                 Host        Tags                   Reasons         Paths                Size
------------------------------------------------------------------------------------------------------------------
c0611b3a  2024-06-30 02:20:08  EDITH       ar:location:important  daily snapshot  /boot
                                                                                  /mnt/user/appdata
                                                                                  /mnt/user/nextcloud
                                                                                  /mnt/user/storage

6785eae3  2024-07-21 02:19:29  EDITH       ar:location:important  daily snapshot  /boot
                                                                                  /mnt/user/appdata
                                                                                  /mnt/user/nextcloud
                                                                                  /mnt/user/storage

bcedf62a  2024-07-23 02:19:48  EDITH       ar:location:important  daily snapshot  /boot
                                                                                  /mnt/user/appdata
                                                                                  /mnt/user/nextcloud
                                                                                  /mnt/user/storage

65571e1a  2024-08-11 02:34:13  EDITH       ar:location:important  daily snapshot  /boot                1.186 TiB
                                                                                  /mnt/user/appdata
                                                                                  /mnt/user/nextcloud
                                                                                  /mnt/user/storage

6d91a402  2024-08-16 02:19:52  EDITH       ar:location:important  daily snapshot  /boot                1.190 TiB
                                                                                  /mnt/user/appdata
                                                                                  /mnt/user/nextcloud
                                                                                  /mnt/user/storage

11c69ed7  2024-08-20 11:53:05  EDITH       ar:location:important  daily snapshot  /mnt/user/nextcloud  929.148 GiB
                                                                                  /mnt/user/storage
------------------------------------------------------------------------------------------------------------------
6 snapshots

remove 2 snapshots:
ID        Time                 Host        Tags                   Paths                Size
--------------------------------------------------------------------------------------------------
981cc9cc  2024-08-20 11:35:35  EDITH                              /mnt/user/nextcloud  929.148 GiB
                                                                  /mnt/user/storage

6c7e399c  2024-08-20 11:44:57  EDITH       ar:location:important  /mnt/user/nextcloud  929.148 GiB
                                                                  /mnt/user/storage
--------------------------------------------------------------------------------------------------
2 snapshots

which gave me

ID        Time                 Host        Tags                   Paths                Size
--------------------------------------------------------------------------------------------------
c0611b3a  2024-06-30 02:20:08  EDITH       ar:location:important  /boot
                                                                  /mnt/user/appdata
                                                                  /mnt/user/nextcloud
                                                                  /mnt/user/storage

6785eae3  2024-07-21 02:19:29  EDITH       ar:location:important  /boot
                                                                  /mnt/user/appdata
                                                                  /mnt/user/nextcloud
                                                                  /mnt/user/storage

bcedf62a  2024-07-23 02:19:48  EDITH       ar:location:important  /boot
                                                                  /mnt/user/appdata
                                                                  /mnt/user/nextcloud
                                                                  /mnt/user/storage

65571e1a  2024-08-11 02:34:13  EDITH       ar:location:important  /boot                1.186 TiB
                                                                  /mnt/user/appdata
                                                                  /mnt/user/nextcloud
                                                                  /mnt/user/storage

6d91a402  2024-08-16 02:19:52  EDITH       ar:location:important  /boot                1.190 TiB
                                                                  /mnt/user/appdata
                                                                  /mnt/user/nextcloud
                                                                  /mnt/user/storage

11c69ed7  2024-08-20 11:53:05  EDITH       ar:location:important  /mnt/user/nextcloud  929.148 GiB
                                                                  /mnt/user/storage
--------------------------------------------------------------------------------------------------
6 snapshots

So still more snapshots that I assumed i would have. I figured i’d only have the last 3 snapshots remaining. Do you happen to know what is going on?

So to make sure I clarify I have changed paths AND changed the forget policy. I did a --parent to backup and then did another backup using autorestic which is nothing more than a wrapper that does the restic commands. I did do this forget policy using restic command directly as I did the --group-by but it didnt’ seem to remove the snapshots I thought it would.

I just did a dry run again on this command: /usr/local/bin/restic forget --tag ar:location:important --prune --dry-run --keep-daily 14

and I get still keeping 6 snapshots, but they do seem to be different based on the paths. Its weird as running a dry run on forget gives me 6 snapshots even if it is just grouping by host.

Are you using some old restic version? Nowadays restic shows “Reason” why specific snapshot is kept e.g.:

$ restic forget --keep-daily 4 --group-by host --dry-run
repository 75d39192 opened (version 2, compression level auto)
Applying Policy: keep 4 daily snapshots
keep 4 snapshots:
ID        Time                 Host             Tags           Reasons         Paths  Size
------------------------------------------------------------------------------------------------
5ff5da1e  2024-08-17 06:44:46  laptop.local  kptsky_backup  daily snapshot  /      41.847 GiB
ec2c597a  2024-08-18 07:31:07  laptop.local  kptsky_backup  daily snapshot  /      41.847 GiB
2391eb51  2024-08-19 17:39:02  laptop.local  kptsky_backup  daily snapshot  /      41.847 GiB
320a076b  2024-08-20 06:56:24  laptop.local  kptsky_backup  daily snapshot  /      41.847 GiB
------------------------------------------------------------------------------------------------
4 snapshots

So run the same as before with the latest restic and it will help you with understanding what is going on.

I’m using restic 0.17.0

root@EDITH:/mnt/user/appdata/autorestic# restic forget --keep-daily 14 --prune --group-by host --verbose --dry-run
repository 8eaa6bd7 opened (version 2, compression level auto)
Applying Policy: keep 14 daily snapshots
snapshots for (host [EDITH]):
keep 6 snapshots:
ID        Time                 Host        Tags                   Reasons         Paths                Size
------------------------------------------------------------------------------------------------------------------
c0611b3a  2024-06-30 02:20:08  EDITH       ar:location:important  daily snapshot  /boot
                                                                                  /mnt/user/appdata
                                                                                  /mnt/user/nextcloud
                                                                                  /mnt/user/storage

6785eae3  2024-07-21 02:19:29  EDITH       ar:location:important  daily snapshot  /boot
                                                                                  /mnt/user/appdata
                                                                                  /mnt/user/nextcloud
                                                                                  /mnt/user/storage

bcedf62a  2024-07-23 02:19:48  EDITH       ar:location:important  daily snapshot  /boot
                                                                                  /mnt/user/appdata
                                                                                  /mnt/user/nextcloud
                                                                                  /mnt/user/storage

65571e1a  2024-08-11 02:34:13  EDITH       ar:location:important  daily snapshot  /boot                1.186 TiB
                                                                                  /mnt/user/appdata
                                                                                  /mnt/user/nextcloud
                                                                                  /mnt/user/storage

6d91a402  2024-08-16 02:19:52  EDITH       ar:location:important  daily snapshot  /boot                1.190 TiB
                                                                                  /mnt/user/appdata
                                                                                  /mnt/user/nextcloud
                                                                                  /mnt/user/storage

11c69ed7  2024-08-20 11:53:05  EDITH       ar:location:important  daily snapshot  /mnt/user/nextcloud  929.148 GiB
                                                                                  /mnt/user/storage
------------------------------------------------------------------------------------------------------------------
6 snapshots

It could be i’m not understanding, but i figured the dates would come into play and the --keep-daily would only keep the latest 14 as in the last 2 weeks.

Check docs for difference between --keep-daily and --keep-within-daily

and experiment not forgetting about --dry-run:slight_smile:

Yea what makes it so confusing is --keep-daily n for the last n days which have one or more snapshots, keep only the most recent one for each day. when it says last n days since 14 here should be last 14 days from today?

It says:

last n days which have one or more snapshots

not

last n days

And yes “last” is not 100% clear english word in this case.

Away from computer so will test this later but do you know off hand if you can couple this with the --keep-within-daily 14d to get a single snapshot per day of the last 14 calendar days?

I do not think so as you are asking for bi-weekly now which is not supported.