Sanoid / Syncoid
sanoid – a policy-driven snapshot management tool for ZFS filesystems.
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
[SAN200/projects] use_template = production recursive = yes process_children_only = yes [BACKUP/SAN200/projects] use_template = backup recursive = yes process_children_only = yes
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.
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 [Unit] Description=Runs syncoid Wants=syncoid.timer [Service] Type=oneshot ExecStart=/usr/sbin/syncoid --recursive --skip-parent SAN200/projects BACKUP/SAN200/projects ExecStart=/usr/sbin/syncoid --recursive --skip-parent SAN300/projects BACKUP/SAN300/projects [Install] WantedBy=multi-user.target
$ more /etc/systemd/system/syncoid.timer [Unit] Description=Runs syncoid Requires=syncoid.service [Timer] Unit=syncoid.service OnCalendar=*-*-* *:10:00 [Install] WantedBy=timers.target
sudo systemctl daemon-reload sudo systemctl restart syncoid.timer systemctl list-timers
man systemd.unit man systemd.service man systemd.time