Sanoid / Syncoid


sanoid – a policy-driven snapshot management tool for ZFS filesystems.

Installation (Ubuntu)

2021-11-28: It seems Ubuntu packages are badly lagging behind so git it and generate the .deb package is better.

sudo cp /usr/share/doc/sanoid/sanoid.conf.example /etc/sanoid/sanoid.conf


We keep the already existing templates.

One key point is that pruning is not done by syncoid but only and always by sanoid. This means sanoid has to be run on the backup datasets as well, but without creating snapshots, only pruning (as set in the template).

Also, the template is called template_something and only something must be use with use_template.

        use_template = production
        recursive = yes
        process_children_only = yes

        use_template = backup
        recursive = yes
        process_children_only = yes

System files location

$ find /lib/systemd -name "*sanoid*"

CAVEAT: post_snapshot_script cannot be used with syncoid

Especially with recursive = yes. This is because there cannot be two zfs send and receive at the same time on the same dataset (details ?).

And, sanoid does not wait for the script completion before continuing. This mean that should the syncoid process take a bit too much time, a new one will be spawned. And for reasons unknown to me yet, a new syncoid process will cancel the previous one (instead of just leaving).

As some of the spawned syncoid will produce errors, the entire sanoid process will fail.

So… no way… this does not work and has to be done independently, it seems.

The good news is that the SystemD service of Type= oneshot can have several Execstart= lines.

syncoid – a tool to facilitates the asynchronous incremental replication of ZFS filesystems.

–identifier=EXTRAExtra identifier which is included in the snapshot name. Can be used for replicating to multiple targets.
–recursive|rAlso transfers child datasets
–skip-parentSkips syncing of the parent dataset. Does nothing without ‘–recursive’ option.
–sendoptions=OPTIONSUse advanced options for zfs send (the arguments are filtered as needed), e.g. syncoid –sendoptions=”Lc e” sets zfs send -L -c -e …
–recvoptions=OPTIONSUse advanced options for zfs receive (the arguments are filtered as needed), e.g. syncoid –recvoptions=”ux recordsize o compression=lz4″ sets zfs receive -u -x recordsize -o compression=lz4 …
–compressCurrently accepted options: gzip, pigz-fast, pigz-slow, zstd-fast, zstd-slow, lz4, xz, lzo (default) & none. If the selected compression method is unavailable on the source and destination, no compression will be used

First time it is used, the target dataset must not exist. After that, it must exist and contain snapshots also present on the source.

sudo /usr/sbin/syncoid --recursive --skip-parent SAN200/projects BACKUP/SAN200/projects
$ /usr/sbin/syncoid --identifier=externalUSB storage/documents USBdrive/documents

This will create the following snapshot on both sender and receiver:


SystemD service and timer

$ more /etc/systemd/system/syncoid.service 
Description=Runs syncoid

ExecStart=/usr/sbin/syncoid --recursive --skip-parent SAN200/projects BACKUP/SAN200/projects
ExecStart=/usr/sbin/syncoid --recursive --skip-parent SAN300/projects BACKUP/SAN300/projects


It seems the Unit= isn’t necessary if the service and the timer share the same name.

$ more /etc/systemd/system/syncoid.timer 
Description=Runs syncoid

OnCalendar=*-*-* *:10:00

sudo systemctl daemon-reload
sudo systemctl restart syncoid.timer
systemctl list-timers
man systemd.unit
man systemd.service
man systemd.time