Skip to content

Instantly share code, notes, and snippets.

@edvler
Last active September 15, 2021 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save edvler/32d65b2fda537a11e1c0db6745a5bc96 to your computer and use it in GitHub Desktop.
Save edvler/32d65b2fda537a11e1c0db6745a5bc96 to your computer and use it in GitHub Desktop.
Howto / Tutorial: Install Urbackup on FreeNAS and ZFS

Install Urbackup 2 on FreeNAS 11

Why install Urbackup on FreeNAS - Some good reasons

  • Usage of ZFS
  • Usage of a true NAS System as storage-backend
    • You can present a Urbackup RAW Images over iScsi (if basic Iscsi is configured, it takes only a minute!)
    • You can share Urbackup File Backups over SMB or NFS
    • Perfect documentation for FreeNAS

Important Note - Keep your path as short as possible

FreeBSD can only mount a path with a length of 88 signs! (Further reading https://forums.freebsd.org/threads/hack-against-88-character-mount-path-limitation-what-is-it.63816/) For this reason i kept the zfs names very short. Because Urbackup is installed in a jail, each path is prepended with the path of the jail itself.

BAD Example: The ZFS-pool is named "FAST-DISKS" and the ZFS Datasets, where the jails are placed, is called "JAILS". Your JAIL name is urbackup01. Then your path /mnt/FAST-DISKS/JAILS/urbackup01 is already 33 signs long.

But in the Jail urbackup01 also zfs mount points exists for Urbackup. The name of ZFS-Dataset for imagebackup is: FAST-DISKS/URBACKUP/VOL01/IMAGE In your Jail this ZFS Dataset is mounted in /mnt/FAST-DISKS/URBACKUP/VOL01/IMAGE The complete path relevant for the mount, because the Jail path is also added, is now /mnt/FAST-DISKS/JAILS/urbackup01/mnt/FAST-DISKS/URBACKUP/VOL01/IMAGE with 69 signs.

If Urbackup now trys to backup the server testserver01 it will fail. Because Urbackup creates another ZFS Dataset with the name of the Server (FAST-DISKS/URBACKUP/VOL01/IMAGE/testserver01) and a ZFS Dataset for the current Backup (FAST-DISKS/URBACKUP/VOL01/IMAGE/testserver01/180530-1939_Image_C).

The complete path for the backup is now /mnt/FAST-DISKS/JAILS/urbackup01/mnt/FAST-DISKS/URBACKUP/VOL01/IMAGE/testserver01/180530-1939_Image_C with 102 signs.

If Urbackup try to mount this path it gets "file name too long" and the backup will fail.

Create a ZFS-Dataset for Jails

  • Use a ZFS-Pool with a short name (e.g. ZFS-Pool s01)
  • Create a ZFS-Dataset with name j (Jails)
  • Goto Jails -> Configuration and choose the ZFS-Dataset j as "Jail Root" (complete path /mnt/s01/j)

Create Jail for Urbackup

enforce_statfs=1,allow.mount=1,allow.mount.zfs=1,allow.raw_sockets=1 
  • Klick "OK" to create the Jail (takes a while)

Basic Jail config

  • Connect with ssh to your FreeNAS Server
  • Connect to your Jail: jexec ub01 csh
  • Enable ssh in Jail:
    • vi /etc/rc.conf
    • Set sshd_enable="YES"
    • service sshd start
  • Set Password for root: passwd root
  • Restart the Jail (Webinterface: Jails -> View Jails -> Red stop button and then green start button)

Open your SSH Client and test if you can connect to your Jail ub01.

Present ZFS-Datasets for backup storage

In this Step three ZFS-Datasets are created. One for the Urbackup Image backups, the second for the Urbackup File backups and the third for the "Backup storage path".

  • Use a ZFS-Pool with a short name (e.g. ZFS-Pool b01 - For Backup Pool 01)
    • Create a ZFS-Dataset b01\u (ZFS-Dataset for all Urbackups)
    • Create a ZFS-Dataset b01\u\01 (ZFS-Dataset for ub01)
    • Create a ZFS-Dataset b01\u\01\b (ZFS-Dataset for ub01 basic for Webinterface -> Settings -> "Backup storage path:" )
    • Create a ZFS-Dataset b01\u\01\i (ZFS-Dataset for ub01 images)
    • Create a ZFS-Dataset b01\u\01\f (ZFS-Dataset for ub01 files)

All ZFS-Datasets has to be created on the same ZFS-Pool (in this example b01)! If you don't place all ZFS-Datasets on the same ZFS-Pool, the free space calculation is wrong.

Some basic informations about Jails and ZFS: In FreeBSD a Jail cannot access ZFS-Datasets until it's allowed. The first step is to set Sysctl's as already done above. The second step is to run some commands after the startup of the Jail on the FreeNAS server to "present" the ZFS-Datasets to the Urbackup Jail and mount the ZFS-Datasets.

  • Login with SSH on your FreeNAS Server
  • Goto you Jail ZFS-Dataset Folder (as configured at the beginning): cd /mnt/s01/j
  • Goto to you ub01 Jail config: cd .ub01.meta
  • Add post start commands (at the end of the file): vi jail-post-start
zfs jail ub01 b01\u\01
zfs set jailed=on b01\u\01
jexec ub01 zfs mount -a
  • Restart the Jail (Webinterface: Jails -> View Jails -> Red stop button and then green start button)
  • Connect with SSH to ub01
  • Execute zfs list: You should see your ZFS-Datasets presented to the Jail ub01
  • Execute df -h: The ZFS-Datasets (and the child datasets) should be mounted in /mnt/b01/u/01

Install Urbackup

  • Startup Jail ub01 (Webinterface: Jails -> View Jails -> Green Start button)
  • Login to ub01 Jail with SSH

Install Urbackup as described here: https://www.urbackup.org/freenasserverinstall.html

  • After install goto to the Webinterface (http://ub01:55414) and set the Backup-Path to /mnt/b01/u/01/b

  • Now configure the ZFS-Datasets for Image Backups and File Backups (Login with SSH to ub01)

  • Restart the Jail (Webinterface: Jails -> View Jails -> Red stop button and then green start button)

  • Login to ub01 Jail with SSH

  • Execute urbackup_snapshot_helper test: ZFS TEST OK should be displayed

  • Open the Webinterface (http://ub01:55414)

  • Goto Settings -> Image Backups: Set "Image backup file format" to "Raw copy-on-write file" to use the efficient backup format

Installation finished

Now you can add your clients to run backups!

Further links

Based on:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment