Forget and prune all snapshots more than 90 days old

That’s not really a great description of it. Restic, and I’d say most other backup software too, will keep your snapshots indefinitely unless you tell it to remove them one way or the other. Same thing here.

As @alexweiss mentioned, when restic grabs the list of snapshots to run your snapshot removal policies on, it takes the full list of snapshots and then groups them into groups that consisting of combinations of host and path, where these two fields are the ones you see in the output from restic snapshots (the latter being the one I was missing in your output earlier). Host and path is the default grouping, but it can be set to any combination of host, path and tags, see restic help forget:

-g, --group-by group                 group snapshots by host, paths and/or tags, separated by comma (disable grouping with '') (default "host,paths")

So if you have e.g. two different hostnames in the list, and each of that hostname has two different set of paths in all its snapshots (e.g. hostA(pathA, pathB) and hostB(pathC, pathD) ) then you restic will put these snapshots into four different groups.

Once restic has grouped the snapshots, it then applies the policy you specified to the forget command to each of these groups individually. So to take a super simple example, if you told restic to keep the three last snapshots, you would with the above example groups end up with three snapshots per group, a total of twelve snapshots since there are four groups.

If in the example above you feel that you dont care about what paths you backed up for each host, and therefore only want to apply the policy for each host (again, regardless of what that host backed up in its snapshots), all you have to do is set the grouping to use only the host field, which is done by adding --group-by host to the forget command.

This is a feature in restic implemented for various reasons, e.g. to support multiple hosts in one and the same repository (without grouping, you could easily end up in a situation where a less frequently backed up host in the same repository is getting all of its snapshots forgotten in favor of a more frequently backed up host, which would obviously be very bad).

If you aren’t happy with grouping on hosts and/or paths and need something more complex you can add tags to your snapshots (see restic help backup and restic help tag) and then use --group-by tags. It really boils down to your scenario etc.

I hope this clarifies how it works, and that there is a good reason for this feature, even if it may have come as a surprise to you. As mentioned earlier, what you probably want to do is to set the grouping to just host by adding --group-by host. From what I’ve read about your case, this should be in line with what you want.

1 Like