Zfsnapr - recursive snapshot mounter

zfsnapr is a tool for creating recursive system snapshots and mounting the result in a given directory tree:

❯ zfsnapr mount /mnt/snapshot
❯ ls -l /mnt/snapshot
drwxr-xr-x   2 root  wheel    48  9 Aug 14:53 bin
drwxr-xr-x  15 root  wheel    71  9 Aug 15:37 boot
-r--r--r--   1 root  wheel  6109  9 Aug 14:53 COPYRIGHT
dr-xr-xr-x   2 root  wheel     2 23 Oct  2020 dev
❯ zfsnapr umount /mnt/snapshot
❯ ls -l /mnt/snapshot
total 0

I use this with BorgBackup to make consistent point-in-time backups without Borg being aware of ZFS - it’s just another directory tree regardless of how the underlying datasets are arranged.

Using --exec, --devfs, --tmpfs and --passthrough it’s also possible to create functional chroot environments within the mounted tree, allowing the migration of existing backup setups without making them aware there even is a special snapshot location to work out of.

I’ve just committed fixes for operation on non-ZFS-on-root systems, so it should Just Work on more setups. You can also now restrict to a given part of the directory tree with --root without it needing to be a mountpoint, so if, say, your /home was canmount=no you can still --root=/home and it’ll mount any datasets within that part of the tree.

zfsnapr is written in Ruby, but has no additional dependencies outside stdlib.


Sort of an automated read-only bind-mount creator, then, but ZFS?

As much as I refuse to live without ZFS replication, I can see where this would come in handy for a bunch of folks who have less control over their environments.