Install Syncoid on TrueNAS Scale, or reinstall after an OS update
TrueNAS Scale is great NAS operating system, based on Debian and incorporating the ZFS file system.
It has built in software to do replication with other systems, with options for cloud sync, rsync and with zfs replication.
The zfs replication option, however, works best with another TrueNAS system.
Some users prefer Sanoid and related programs to do zfs replication, which is a Perl script and related config files and systemd units.
Sanoid can be easily installed on most linux operating systems via the native package manager, or manually. Installing on TrueNAS Scale is not as simple, however, because the Debian operating system underneath is deliberately locked down in a few ways, to help the reliability and predictability of TrueNAS Scale. The NAS software is provided as a complete appliance, and it's developers strongly encourage not changing the underpinning OS directly.
Additionally, updates to TrueNAS Scale are provided somewhat atomically. If changes are made to files outside the data storage areas, the changes are overwritten on some (every?) operarting system update.
This script makes it easier to break the 'no end user servicable parts inside' sticker they've applied to TrueNAS. Please note this is strictly at your own risk. If it breaks, you get to keep the pieces, and I get to say "I told you so"
You will need an account on the NAS that can su to root. Typically the first local user you set up will be able to do so. In the script provided, that user is 'admin' If you wish to use a different account, please edit the script to match.
In that user's home directory, place the following nine files, from the sanoid project, and the enable-syncoid-on-truenas.sh script.
- findoid
- sanoid
- sleepymutex
- syncoid
- sanoid.conf
- sanoid.defaults.conf
- sanoid-prune.service
- sanoid.service
- sanoid.timer
Edit the sanoid.conf file to match your requirements.
Log into your TrueNAS via the web console or ssh, and run sudo enable-syncoid-on-truenas.sh
The script should run to the end without error and report completed successfully
Some warnings from apt are normal, but not errors.
If it does not, please review the output and/or the log file at /var/log/setup-script.log
carefully.
By default, the script puts /usr back as a read-only folder, but that does not happen if the run is interupted. The next system restart will restore the read-only state as well.
After every TrueNAS update, you should check if sanoid exists and is executable, and re-run this script if it's not present.
For more information, and discussions of ZFS or Sanoid, I recommend the Practical ZFS discussion site.
Feedback, suggestions and patches are welcome, although speedy responses are not guaranteed. :-)