Restic forget & subfolders

I’m having a little confusion about how restic forget handles snapshots with different folders. My understanding is that forget is run separately on each collection of snapshots with a different path, but I’m not sure. If I have two snapshots with folders


is the forget algorithm clever enough to see that one path is a substring of the other? If not, is there a way to force these snapshots into the same collection, say giving them the same tag?

I personally havn’t tested this but restic probably thinks they are 2 different directories. If uncertain you can always run restic forget --dry-run to test everything out before eventually deleting anything.

Using tags is a clever idea to combine such snapshots to enforce 1 policy on them. Tags can be added and removed at any time.

restic treats the folders indeed as different, it isn’t intelligent enough to see that one is a subfolder of the other. You can configure the grouping criteria for restic forget with the --group-by option, by default it’s set to host,paths so that groups are built by host and by path. If you set this to --group-by tags, only the tag is considered. In addition, you can limit which snapshots are considered for deletion with --tag foo.

Please use --dry-run a lot, it’ll tell you what it would delete so you can experiment. :slight_smile:

Thanks for the dry run tip. Word of caution for anyone coming across this thread with the same use case/problem, I notice that grouping by thread with multiple tags per snapshot may not work as expected.

Would you mind elaborating on that? Do you maybe have an example, so I can try to understand what’s going on (and we can improve the documentation)?

Sure, maybe it makes sense after thinking about it a while, but I found that each combination of tags is grouped separately, where I was expecting forget to run separately on each tag. I am assuming that the grouping is intended to create a partition so the final result does not depend on the ordering in which each group is processed?

Hm, still hard to understand, can you please make up a simple example? (maybe we can even add this to the docs later, with an explanation what’s going on?)