Backup with Ubuntu (on ZFS) + sanoid/syncoid on a schedule

Managing Ubuntu backups with Sanoid/Syncoid is simple and can be automated in a crontab!

This is a follow up to Ubuntu 20.04 -> TrueNAS (FreeNAS), ZFS Backup where we set up scheduled backups for an Ubuntu computer.

The backups will be hourly, incremental, and transferred to a NAS running ZFS (such as Truenas).

For handling the automated snapshots and incremental transfers I used sanoid/syncoid which makes automating ZFS tasks easy!

GitHub - jimsalterjrs/sanoid: Policy-driven snapshot management and replication tools. Using ZFS for underlying next-gen storage. (Btrfs support plans are shelved unless and until btrfs becomes reliable.) Primarily intended for Linux, but BSD use is supported and reasonably frequently tested.
Policy-driven snapshot management and replication tools. Using ZFS for underlying next-gen storage. (Btrfs support plans are shelved unless and until btrfs becomes reliable.) Primarily intended fo...

Follow the installation instructions from the repo, and configure your backup schedule in /etc/sanoid/sanoid.conf.

You'll want one backup schedule for each of rpool/USERDATA, rpool/USERDATA, and bpool/BOOT so that you can back up all ZFS pools.

5  * * * * syncoid --no-sync-snap --recursive  --no-privilege-elevation --sshkey=/home/username/.ssh/key-nas   bpool usernameNAS@192.168.1.9:nas/LiveBackups/ubuntu/bpool
10 * * * * syncoid --no-sync-snap --recursive  --no-privilege-elevation --sshkey=/home/username/.ssh/key-nas   rpool/USERDATA usernameNAS@192.168.1.9:nas/LiveBackups/ubuntu/rpool>
15 * * * * syncoid --no-sync-snap --recursive  --no-privilege-elevation --sshkey=/home/username/.ssh/key-nas   rpool/ROOT usernameNAS@192.168.1.9:nas/LiveBackups/ubuntu/rpool/ROOT
crontab commands to transfer snapshots hourly to NAS

Don't forget that you may need to remove old snapshots with the sanoid configuration (or else you might end up with tens/hundreds of thousands of snapshots). If you need to figure out how to list snapshots, see here, or you can learn how to remove old snapshots manually.

With this configuration, my Ubuntu desktop now regularly backs itself up to my Truenas server. ZFS is amazing in how simple it is to send ZFS snapshots and incremental backups to a NAS. Thank you syncoid and sanoid for simplifying the process further!

2023 Update: I now use ZFS on Ubuntu 22.04. Sanoid is still working great on this installation too.