Remove all ZFS snapshots
Here’s a small bash script to destroy all existing zfs snapshots.
Run at your own risk!
#!/bin/bash
for snapshot in `zfs list -H -t snapshot | cut -f 1`
do
zfs destroy $snapshot
done
for snapshot in `zfs list -H -t snapshot | cut -f 1`
do
zfs destroy $snapshot
done
Last updated by .
Related posts:
SysAdminMan provides virtual PBX hosting based on Asterisk and Freeswitch.
Avaialble systems include FreePBX, PBX-in-a-Flash, Elastix, A2Billing and FusionPBX.
More details and prices can be found at sysadminman.net
Avaialble systems include FreePBX, PBX-in-a-Flash, Elastix, A2Billing and FusionPBX.
More details and prices can be found at sysadminman.net

slawko:
Hi,
It’s better to get rid of cut command:
for snapshot in `zfs list -H -o name -t snapshot`
(…)
23 April 2009, 12:50 pmAnders:
Well,
zfs list -H -o name -t snapshot | xargs -n1 zfs destroy
is even better
18 December 2009, 8:07 pmLuke Sheldrick:
Nice. Ta
24 May 2010, 10:26 amhseldon:
I found that when deleting snapshots from multiple shares this works okay:
zfs list -H -o name -t snapshot|grep nameofzfsshare|pfexec xargs -n1 zfs destroy
4 December 2011, 4:09 pmMihai:
while trying the same thing we came up with this line
It helps to see what is going to be deleted
zfs list -H -o name -t snapshot | grep | while read SNAPSHOT;do echo $SNAPSHOT; zfs destroy $SNAPSHOT;done
4 May 2012, 11:52 amMihai:
This is an edit because first post was truncated
while trying the same thing we came up with this line
It helps to see what is going to be deleted
zfs list -H -o name -t snapshot | grep nameofsnapshot| while read SNAPSHOT;do echo $SNAPSHOT; zfs destroy $SNAPSHOT;done
4 May 2012, 11:53 am