Forgetting all snapshots with a specific tags


#1

I’ve not been able to figure out how to forget ALL snapshots with a specific tag. Is it possible? I can remove all except for the very last one …

restic forget --tag tmp -l 1 -g tags

and it’s quite involved


#2

Yep, that’s the easiest way to remove all snapshots with a given tag. The idea of the forget command is to specify a retention policy, forgetting all snaphots which match some criteria is not its primary focus. So you have to bend it a little bit. Alternatively, you could use restic snapshots --json, filter the output e.g. with jq, and pass the IDs of the snapshots you’d like to forget to restic forget.


#3

wouldn’t forget all given matching tags qualify as a retention policy ? retain none


#4

Let me clarify my use case.

In stead of doing a huge backup at once spanning a long time, I broke it into smaller chunks that could finish when I wasn’t using my bandwidth for work.

I marked all such backups with the tmp tag with the idea of adding them to my monthly backup (monthly tag) that would be able to finish quickly later due to de-dup.

then I went back to delete all the backups with the tmp tag.


#5

I understand what you’re trying to do. For safety reasons, a policy that retains no snapshots at all for a given list of snapshots is not considered valid, so restic refuses to do anything. For such a situation I think it’s not too much to ask from users to forget all but the last of the tagged snapshots, and remove that one by hand. :slight_smile: