Eliminate zfs-auto-snapshots on certain ZFS filesystems and delete all snapshots


I have zfs-auto-snapshot installed and it works great to simply make a ton of snapshots of every zfs filesystem, making time machine like access simple. However, I have two zfs filesystems where the snapshots are using way too much space, and are unnecessary since they are used only for backups.

Use the following command to see how much space is used by snapshots for each zfs filesystem:

zfs list -o space

My “data/SystemBackups” had 92 GBs of current data and 564 GBs of snapshot data. That needs to be freed, and I don’t want to deal with deleting snapshots on that filesystem regularly. The command to disable the auto-snapshots in this case is:

zfs set com.sun:auto-snapshot=false data/SystemBackups

Then to delete the old ones I used this command, with the -n option to first test it:

zfs destroy -rnv data/SystemBackups@%

The response was a list of all the snapshots and the following:

...
would destroy (snapshot names)
would reclaim 564G

Bingo, just what I wanted, so I issued the not-test command:

zfs destroy -rv data/SystemBackups@%

I also found the following bash script to easily destroy all zfs-auto-snapshot snapshots: http://pastebin.com/3pLJZa2E

Leave a Reply

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