How to forget and prune snapshots for specific host?

Hi. I have repository which contains snapshots for multiple hosts. I want to remove/forget/prune all snapsots that belongs to myhost.com. How can I do this? I read documentation here but still don’t understand how to do this Removing backup snapshots — restic 0.16.2 documentation

The option to limit the delete operation to snapshots to a specific host is --host hostname.

But I couldn’t find an option to remove all snapshots in one go, too. I think the best approach would be to delete all but one snapshot, and then delete the last one too.

So e.g.:

  1. Forget all but one snapshot:
    restic forget --host myhost.com --keep-last 1 (unfortunately --keep-last 0 does not seem to work)
  2. Find the last snapshot ID:
    restic snapshots --host myhost.com
  3. Forget the last snapshot using the ID from above:
    restic forget <ID>
  4. Optional: Clean all now obsolete data from the repository:
    restic prune
1 Like

See https://forum.restic.net/t/delete-all-snapshots-in-one-command-is-this-feature-intentional/

It is declared as bug, but with current restic you can do
restic forget --host myhost.com --keep-tag=SomeUnusedTag

Always ensure you are using --dry-run until you are satisfied with the result!

1 Like

That worked, thanks!