LXD, namespaces and zfs_autobackup

I’ve recently been investigating what might be the most simple and efficient way to backup my LXD containers whilst retaining their ZFS snapshots. The best I’ve come up with is using something like zfs_autobackup to replicate the container dataset(s) onto a remote ZFS pool and then restoring using the new lxd recover tool.

I’ve not actually tried this yet because I’ve not yet configured the target machine I plan to use to store the backups but I’m pretty certain that snaps use of namespaces (and hence LXD’s use of them, because I am using the 20.04 snap package) is going to make setting this up trickier than it would be otherwise.

Has anyone else used zfs_autobackup (or something similar) or even just plain zfs send and receive to replicate their snap-based LXD ZFS pool? What steps were required to make it work, if you were able to use it?

That shouldn’t really be a problem, zfs doesn’t need a dataset to be mounted in order to send/receive it and the main improvement for lxd recover over our old lxd import is that it doesn’t need the datasets to be mounted inside of the namespace in order to import them.

1 Like

Thanks stgraber! Yes, I was wondering if I’d need to switch namespaces or mount the dataset before running zfs_autobackup. Thankfully that shouldn’t be required.