Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
backupandforkacc opened this issue Feb 9, 2023 · 1 comment

Comments

@backupandforkacc
Copy link

backupandforkacc commented Feb 9, 2023

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 backupandforkacc changed the title [Docu] Full instructions to setup zfs backups for ubuntu jammy 22 (backup to external disk) with sanoid/sycoid [Docu] Full instructions to setup zfs backups for ubuntu jammy 22 (backup to external disk) with sanoid/syncoid Feb 9, 2023
@MynaITLabs
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants