Note to self:
Sometimes it is necessary to destroy not just a single but multiple ZFS snapshots. This can be done with some command line magic, but the zfs destroy subcommand has built in functionality too.
Given a dataset pool1/dataset1 with 5 snapshots:
- snapshot1
- snapshot2
- snapshot3
- snapshot4
- snapshot5
zfs destroy pool1/dataset1@snapshot1,snapshot2,snapshot4
will destroy snapshot1, snapshot2 and snapshot4 in one go, leaving snapshot3 and snapshot5.
zfs destroy pool1/dataset1@snapshot1%snapshot3
will destroy snapshot1, snapshot3 and all snapshots in between (snapshot2) in one go, leaving snapshot4 and snapshot5.
It’s also possible to combine the two
zfs destroy pool1/dataset1@snapshot1%snapshot2,snapshot4%snapshot5
will destroy all snapshots but snapshot3.