sanoid icon indicating copy to clipboard operation
sanoid copied to clipboard

[Docu] Full instructions to setup zfs backups for ubuntu jammy 22 (backup to external disk) with sanoid/syncoid

Open backupandforkacc opened this issue 2 years ago • 1 comments

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.

  1. 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
  1. 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

  2. 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"

  3. Make a zfs pool on external disk. // I have to edit this later

  4. Sync the local snapshots to external drive by syncoid -r rpool backup-sam15tb

backupandforkacc avatar Feb 09 '23 13:02 backupandforkacc

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
  1. 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.

MynaITLabs avatar Jun 05 '23 20:06 MynaITLabs