Solved Remove unwanted snapshots

I am experimenting with zfs send | receive and I have created multiple snapshots of a test file system. I would like to get rid of them all.

The snapshots were created using the following command:
Code:
export XFRDATE="$(date +'%Y-%m-%d_%H-%M-%S')" && \
  zfs snapshot -r zroot/iocage/jails/testjail2@send_rcv_host_xfr_"$XFRDATE

The number of snapshots are not large but I decided to eliminate them anyway. The documentation seems to imply that one cannot do anything along the lines of zfs destroy -rp zroot/iocage/jails/testjail2@send_rcv_host_xfr_*. At least I am unable to get this to work.

Code:
zfs destroy -npr zroot/iocage/jails/testjail2@send_rcv_host_xfr\*
could not find any snapshots to destroy; check snapshot names.

zfs destroy -npr zroot/iocage/jails/testjail2@send_rcv_host_xfr*
could not find any snapshots to destroy; check snapshot names.

Is one required to write a script to iteritively find and destroy each snapshot?

A. Apparently the answer is YES. I found such a script on github named zfs-prune-snapshots.
 
Work from this:
zfs list -r -t snapshot -H -o name | grep <something> | xargs -n 1 zfs destroy

Run this a couple of time without the destroy pipe and verify the list is really what you want to throw away.
 
Back
Top