Clear All ZFS Snapshots

If you’ve been running snapshots for a while and have already backed them up, you might occasional need to delete all zfs snapshots for your pool.
Typically, you’d do this as part of your backup script, assuming that they have been written correctly.

First, to find the used snapshot space, run this command:
zfs list -o space
This will give you a detailed readout of your pools and snapshot space used.

Here’s my script to wipe ZFS snap shots, but I am certainly open to suggestion:
zfs list -H -o name -t snapshot | xargs -n1 zfs destroy
Again, caution is needed as this will remove ALL SNAPS from your pools.

Join the Conversation

5 Comments

  1. To destroy all snapshots for a specific filesystem use: `zfs destroy -nv filesystem@%`

  2. Thank you Andy and Robert, very helpful suggestions. I love snapshots but I just moved a lot of data around and my snapshotting tool (zap) is great at managing snapshots but provides no way to mass clear them. I’ve got my disk space back, thanks again!

  3. !!BEWARE!!
    Neither of the commands given in the comments will work as described. The destroy -nv will simply list what would be destroyed if the -n flag was not used. destroy -rv will destroy all snapshots AND THE UNDERLYING DATASET.
    In general, please do not blindly type in ANY commands you find on the internet into ANY system that you care about.

Leave a comment

Leave a Reply to Peter Kruk Cancel reply

Your email address will not be published. Required fields are marked *