sanoid
sanoid copied to clipboard
[Docu] Full instructions to setup zfs backups for ubuntu jammy 22 (backup to external disk) with sanoid/syncoid
To me it was not clear how I had to install and setup sanoid, so let me share what I did and you are welcome to discuss.
- Install sanoid by apt
Install prerequisite software:
apt install debhelper libcapture-tiny-perl libconfig-inifiles-perl pv lzop mbuffer build-essential
This lead to an error for me, I had to do:sudo apt-get install libc6=2.35-0ubuntu3
It seems a problem with apt lists for ubuntu 22 (Jammy). Might work with 20 without that line.
Clone this repo, build the debian package and install it (alternatively you can skip the package and do it manually like described below for CentOS):
Download the repo as root to avoid changing permissions later
sudo git clone https://github.com/jimsalterjrs/sanoid.git
cd sanoid
checkout latest stable release or stay on master for bleeding edge stuff (but expect bugs!)
git checkout $(git tag | grep "^v" | tail -n 1)
ln -s packages/debian .
dpkg-buildpackage -uc -us
apt install ../sanoid_*_all.deb
Enable sanoid timer:
enable and start the sanoid timer
sudo systemctl enable sanoid.timer
sudo systemctl start sanoid.timer
-
Edit the configuration Make a sanoid folder under /etc by
mkdir /etc/sanoid/
Edit the configuration. You can use this as an example:/usr/share/doc/sanoid/examples/sanoid.conf
-
Make some cron jobs:
crontab -e
and add these lines: */15 * * * * root flock -n /var/run/sanoid/cron-take.lock -c "TZ=UTC sanoid --take-snapshots" */15 * * * * root flock -n /var/run/sanoid/cron-prune.lock -c "sanoid --prune-snapshots" -
Make a zfs pool on external disk. // I have to edit this later
-
Sync the local snapshots to external drive by
syncoid -r rpool backup-sam15tb
To me it was not clear how I had to install and setup sanoid, so let me share what I did and you are welcome to discuss.
Enable sanoid timer:
enable and start the sanoid timer
sudo systemctl enable sanoid.timer sudo systemctl start sanoid.timer
- Make some cron jobs:
crontab -e
and add these lines: */15 * * * * root flock -n /var/run/sanoid/cron-take.lock -c "TZ=UTC sanoid --take-snapshots" */15 * * * * root flock -n /var/run/sanoid/cron-prune.lock -c "sanoid --prune-snapshots"
FYI, I think that 'system timers' and 'crontab' are mutually exclusive. You should really only have system timers (preferred) OR crontab jobs, otherwise things get a little confused with zfs. Not even sure why you are doing 'flock' every 15 mins in crontab, if it is something necessary, you could just do it in the 'system timer' too.