I am still very new to zfs, but I wanted to compliment my Cool shell tricks post with zfs stuff so I don't lose commands that I like. I am not going to give more detail than a simple description, but you should always be able to post the commands in https://explainshell.com/ as well as the openzfs man page to get a better understanding of how things are getting executed.

NOTE: proceed with caution, this is your data so I don't claim it won't do damage to your data or you won't have specific snapshots if you run these commands and don't know what they are doing...trust me I had this happen too many times to me to not put a notice...

ZFS rollback script

I made a post here about this script, but here is another example from my zsh history that I used for it.

curl -fsSL 'git.io/Jf047' | sudo bash -s 'rpool' 'autozsys_mf440q' '<username>_mgspym' |& tee ~elbruto/"zfs-rollback_$(date -I).log"

Snapshot space enumeration

Identify all the snapshots for a given pool that are taking up gigabytes of space, so you can remove them.

POOL='rpool' ; for i in $(zfs list -Ht snapshot -o name -r "${POOL}" | cut -d '@' -f 2 | sort -u ) ; do zfs destroy -vRn "${POOL}@${i}" ; done | grep -B 1 reclaim | grep -B1 'G$'

Cleanup zfs-auto-snap

delete all the zfs-auto-snap snapshots.

pool_name='rpool' ; touch ~/"deletion-${pool_name}.log" && rm ~/"deletion-${pool_name}.log" && for i in $(zfs list -t snapshot | grep "${pool_name}" | grep 'zfs-auto-snap' | awk '{print $1}') ; do sudo zfs destroy -v "$i" | tee -a ~/"deletion-${pool_name}.log" ; done