the --dry-run so you won’t actually delete your snaphots by copy pasting my command… Of cause assuming you have environment with the repo and password.
The docs indicate restic won’t allow deleting all snaphots in one fell swoop, but that only applies to all the other --keep-* commands.
I discovered this because I’m using the very nice resticprofile, and created a parent with forget/retention which only had my --keep-tag=forever line, but that meant it was applied to all those profiles which didn’t have a definition. I suspect a similar thing could happen to users who using scripts try to create a hierarchy of configurations. Fortunately it had only deleted my snapshots for a minor backup, and everythings fine. Though it also makes me more hesitant to prune, in case I mess up again in the future…
Good catch! I also think it’s a very dangerous bug. I can reproduce with restic 0.15.2.
But what would be the better behavior?
An error message if the tag name does not exist in any snapshot?
An error message if the tag name does not exist in any of the otherwise selected snapshot? That would require to first run all other keep policies before getting to the tags.
Allow --keep-tag only in combination with other, stronger --keep-* options?
I think the sane thing is to disallow only --keep-tag, just like currently it is not allowed to forget without any keep-*.
All the other keeps are time or count based. Thus they fit well with --keep-tag. --keep-tag makes little sense alone, unless you want to erase your repository, in which case rm -rf also works. That was said a bit tongue-in-cheek, but I also think there a point to be made. Normally you want to keep your latest snapshot, --keep-tag goes around that, which, I think, was not intended. Or @fd0 may correct me on the intention.