Destroy ZFS snapshots matching a keyword

I’ve got too many snapshots but I don’t want to delete them all. No one seems to have written down the required magic.

The following worked for me:

zfs list -r -t snapshot -o name big/stuff | grep aaarrghh | xargs -n1 zfs destroy 

It will delete all snapshots with the word ‘aaarrghh’ in its name from the file-system ‘big/stuff’.

Written on 22 March 2021

Twitter, LinkedIn, Facebook