Automating incremental snapshot backups from a desktop Linux distribution also on ZFS root

I see topics about backing up the TrueNAS machine to another site machine. I also see topics about backing up Linux machines using btrfs or other non-ZFS formats. I don’t see a whole lot about backing up from a Linux distribution that is also using a ZFS rootfs, automated. I found some things using sanoid and similar, but problems with those things. Not to mention, they don’t easily automate pruning the snapshots on the target side.

Does anyone know a good procedure for installing something on an Arch Linux machine, AUR is acceptable as a source of packages, which can automate timed atomic snapshots of selected datasets on the desktop, and send them over SSH to a TrueNAS Scale machine, to write to a dataset there? Preferably with the ability to prune both sides.

I am in the same situation and my plan is roughly this:

  1. sanoid for PC snapshotting
  2. syncoid for syncing to truenas

TrueNAS side:

  1. A container with syncoid running configured to not take snapshots
  2. A data set to be managed exclusively by syncoid.

I am yet to start executing the plan. I just need to split my backup dataset into multiple ones first.

1 Like

Just remember to add recursive = zfs in your config file, otherwise recursive snapshots will not be atomic.

Here’s how I did it on my Proxmox hosts using ZFS; I’d expect the same procedure would work on any other Linux system running ZFS:

3 Likes

Wow, awesome, you did it entirely with a pull method from TrueNAS itself, with the only setup on the source machine(s) being something to create the snapshots. I’ll go ahead and mark this as a solution once I’ve managed to recreate it.

…and adding a SSH key to authorized_keys. But yes, zfSnap handles the snapshots on the host machine (including pruning them), and entering the naming schema into the TrueNAS task allows it to prune appropriately as well.

1 Like

Pulling to a centralized backup server is always my method. Keeps from from having to log in to many different systems. I log in to one system and configure all my backups there instead of the other way around.

The instructions needed some amending for the version of zfsnap available to me, but otherwise, excellent.

Old:
zfsnap -a 5d -r rpool

New:
zfsnap snapshot -a 5d -r rpool

Added, on a daily timer:
zfsnap destroy -r rpool

I LOVE that. Never knew about zfsnap. sanoid/syncoid is an overkill compared to this :slight_smile:

Thank you

I used GitHub - aaronhurt/zfs-replicate: POSIX compliant shell script to manage ZFS snapshot replication locally, or between hosts. for a long time but found the -R method really touchy for large replications.

I modified it to GitHub - tschettervictor/xync: POSIX compliant shell script to manage ZFS snapshot replication locally, or between hosts. Created with XigmaNAS in mind. which does it like zettarepl (no -R, but handles each dataset by itself)