/etc/apt/apt.conf.d/71backup
DPkg::Pre-Install-Pkgs {"/sbin/zfs snapshot rpool/ROOT/debian@apt-get_$(date '+%Y-%m-%d-%H%M%S')";};
When I inevitably break Debian with no time to troubleshoot, I do # zfs list -t snapshot | grep apt\-get
...
# zfs rollback -r rpool/ROOT/debian@apt-get_<insert time stamp here>I haven't touched ZFS since it first came out on Solaris around 2008ish (we had a 48 drive "x4500", great hardware, but solaris :/ )
Are the snapshots instant? I'd be tempted to replace "sudo" with something that snapshotted them too!
Yes. But you have to remember to delete the old ones at some point.
Yes, it just copies & stores the block at the top of the filesystem[0], in the same way naming a git tree will keep its content recursively alive.
However all the data in the snapshot is retained as-is until the snapshot is destroyed, so as the system keeps being used and diverges from the snapshot the snapshot is slowly going to "increase in size" compared to the live FS.
[0] there's also a more recent "checkpoint" concept which "saves" the entire pool by copying the uberblock.
This is such a simple thing, and yet it somehow didn't occur to me until now... if ZFS is your OS's root filesystem, you can use ZFS snapshots to capture and roll back the complete state of your system. Just like that, no other special tools needed. Wow.