ZFS recursiv snapshot rollback

I’m using zfs snapshots to save all non global zones filesystems via cron. This can be achieved using the zfs snapshot option “-r”. During snapshot creation this means

create snapshots on the target filesystem and all descendants filesystems

If made a mistake and you want to rollback the last action you will be disappointed that the corresponding “-r” option of the zfs rollback command has a different meaning:

destroy snapshots newer than the specified snapshot

All posts in the internet that I found show that there is no way to make a recursiv rollback with just using zfs. A small shell script can help to make recursiv rollbacks:

zfs-recursive-rollback

Of course you have to make the file executable after copying it to your system with a command like

You should also adapt the command line options in the script to your needs if the options in the script do not fit.