As described in this post post, i modified the awesome script from Jörg Binnewald @ https://esc-now.de/ to suit my needs.
The script is automatically triggered, when the backup-HDD is attached to the TrueNAS-Server. The Datasets (and child-Datasets) are incrementally backed-up via send/receive (ZFS feature). This script can be used for TrueNas, as well as for Linux machines.
- truenas.poolbackup.sh (Backup script, triggert by devd rule)
- Example file "truenas-poolbackup-conf-example.env" provided - rename to truenas-poolbackup-conf.env
- devd-backuphdd.conf (devd rule, connecting HDD)
- truenas-copy-devdconf.sh (Workaround, because TrueNas keeps killing the devd rule)
- Folder "restore" (scripts to mount and unmount the backup HDD on a linux maschine; not needed if you use the script for TrueNas)
- Folder "homebackup" (helper scripts to run in my local Linux maschine to backup the home folder; not needed if you use the script for TrueNas)
- configure the devd-rule, and change the config in truenas-poolbackup-conf.env to suit your needs
- place the script on a safe place in your datapool (as the system partition is not upgrade safe)
- you may run the script manually, there are parameters available:
- -h show help
- -f force scrub (even if the condition, number of passed days) is not met
- -d dry run (do not do the actual backup)
- -c specify non-standard config-file
- -y don't ask when creating/overwriting/deleting folders in backup (caution: intended to be used on initial backups; could cause data loss on existing backup data)
- execute truenas-copy-devdconf.sh to enable auto backup when configured HDD is attached