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:


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.

3 thoughts on “ZFS recursiv snapshot rollback

  1. Thanks for the script. Doesn’t make sense to me why there isn’t an option to do this. I’d imagine a full rollback is fairly common usage.

  2. Thank you very much for the script! Saved me a lot of work. I’m also surprised that there wasn’t a option to do so.

Leave a Reply

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

This blog is kept spam free by WP-SpamFree.