Freenas COW with different datasets

First thanks to uroni for this software. Thanks

I am trying to follow the manual to setup UrBackup in Freenas with the ability to make COW and have a dataset for files and another for the images.
urbackup_snapshot_helper test is saying ok and i am able to create subvolumes from inside the jail
but I do not realy understand the meaning of the backup path
/mnt/BACKUP/urbackup
which should be set by
echo “/mnt/BACKUP/urbackup” > /etc/urbackup/backupfolder.

Sorry for beeing a noob

Should be the same path as in the global server config in the web interface. It is because urbackup_snapshot_helper is a setuid executable (which runs as root), so it cannot use the web interface settings.

Thanks for the quick reply.
It is the same path as in the global server config.
But urbackup can not go for it. There is no /mnt/BACKUP/urbackup.
I only have a /mnt/tank0/images and /mnt/tank0/files after urbackup_snapshot_helper.
Or did i totaly missunderstood your guide?

I setup a jail in freenas. Set up the sysctl for this jail and created two other datasets:
1 tank0/images
2 tank0/files
setting the jailed propertys to tank0/images and tank0/files so that i can snap, create and destroy from inside the jail
install urbackup in jail run urbackup_snapshot_helper and have in mnt mnt/tank0/images and mnt/tank0/files.
How would a the path to the backup location look like so that files are backing up in mnt/tank0/files and images in mnt/tank0/images.

Or is it only possible with this method to either backup images or files?
Or do i still need another mounted dataset for example mnt/backup like in the normal setup?

Ok… after stumbling around blind i think i got in the right direction.
Here are !hints! for noobs like me in the same situation but be carefull these are only hints and not the final solution.
!I am still asking for help in this topic!
And sorry for my english…

uroni could you please take your time and have a look over this. Maybe i break something which i do not know. Thanks.

the goal is to get Copy-on-write raw image and file backups with ZFS working in a freenas jail where UrBackup puts each backup into a separate dataset and stores the image backup and file backup as a single big file.

configure jail (add an own dataset for your jails).
While using the extended view create a jail (urbackup) with sysctl’s as folowed :
allow.mount,allow.mount.zfs,allow.mount.devfs,enforce_statfs=1,allow.raw_sockets=true
Create another dataset like tank/backup where tank is the name of your pool, change it to your needs.
Add this dataset to the jail as storage with the mountpoint /mnt/backup
Create another dataset like tank/images where tank is the name of your pool, change it to your needs.
This is the dataset in which the image backup datasets gets created.
Create another dataset like tank/files where tank is the name of your pool, change it to your needs.
This is the dataset in which the file backup datasets gets created.
In freenas open the shell of the jail and
update/upgrade the jail (“pkg update” and then “pkg upgrade”). !Beware of a potential mismatched Kernel!
Install cryptopp (“pkg install cryptopp”) and if you like install nano (“pkg install nano”)
add a user, with password, invite this user additional to group wheel .
add the user urbackup, without password and invite him to group wheel.
It happened to me that the install of Urbackup ended with errors because the user urbackup and his group were not set correctly during the installation. So it is nice to have both before install. If not you can run into permission problems.
enable ssh:
“nano etc/ssh/sshd_config”
change
#PasswordAuthentication no
to
PasswordAuthentication yes
than
“nano /etc/rc.conf”
change
sshd_enable=“NO”
to
sshd_enable=“YES”

Restart the jail and ssh into the jail with the new user and become root “su”
Install urbackup like it is described at https://www.urbackup.orgfreenasserverinstall.html
without point 4. and do not restart now.
Switch over to the Administration Manuel of urbackup and there to chapter 11.7.2 and do
“mkdir -p /etc/urbackup”
echo “tank/images” > /etc/urbackup/dataset where tank is the name of your pool, change it to your needs
echo “tank/files” > /etc/urbackup/dataset_file where tank is the name of your pool, change it to your needs
echo “/mnt/BACKUP/urbackup” > /etc/urbackup/backupfolder
where /mnt/BACKUP/urbackup is in this example /mnt/backup because we had mounted tank/backup to the jail as storage for the jail at /mnt/backup.
close the ssh session to the jail.
Open a shell in freenas or ssh in freenas and set the zfs jail properties:
“zfs set jailed=on tank/images” where tank is the name of your pool, change it to your needs
“zfs set jailed=on tank/files” where tank is the name of your pool, change it to your needs.
“zfs jail urbackup tank/files” where tank is the name of your pool, and urbackup the name of the jail change it to your needs
“zfs jail urbackup tank/images” where tank is the name of your pool, and urbackup the name of the jail change it to your needs.
In freenas restart the jail, open the shell of the jail or ssh into the jail and type
“zfs list” to test wether the jail see the datasets tank/images and tank/files.
If you see tank, tank/images and tank/files, test with “zfs create pool/images/test” wether you have the permission to create a subdataset
If yes start urbackup as root typing:/usr/local/bin/urbackupsrv run -d -g 104857600 -u root
Afterwards test if everything is working correctly by running as root:
“urbackup_snapshot_helper test”
As far as i understand, this script is testing wether it is possible to create and destroy a datase within the jail and it is setting the symlinks to tank/images and tank/files. Only if there is a zfs okay as a result everything is fine and you can choose the raw copy on write format (in german: Binärkopie bei Lesevorgang) in the webfrontend of the server what you have to do for getting the whole thing to work.

There is a problem: everytime you restart the jail or freenas the zfs properties are gone!
So i came to the solution to use a hook. We need a hook that gives us the oportunity to set the zfs properties after the jail has started and than start urbackup.
The hook is in the jails dataset which you have configured first where you put in all your jails and urbackup is in it as well.
Go into this dataset (example cd /mnt/tank/jails) and type “ls -a”.
You will find a meta like .urbackup.meta where urbackup is the name of your urbackup jail.
Just enter “cd .urbackup.meta” and you will see lots of available hook scripts.
We use the jail-post-start script so “nano jail-post-start”
For me this script is working:

#!/bin/sh

. /etc/rc.freenas

jail_post_start “${JAILNAME}”

zfs jail urbackup tank0/images
zfs jail urbackup tank0/files
zfs set jailed=on tank0/images
zfs set jailed=on tank0/files
jexec -U root urbackup /usr/local/bin/urbackupsrv run -d -g 104857600 -u root

(I have changed the script to jexec -U root urbackup /usr/local/bin/urbackupsrv run -d -g 104857600 -u root
at 12.03.18 ca. 22.15 pm because with the first call we do not get root for urbackupsrv)
Restart the jail or freenas and it should work.
ssh in urbackup and test with “urbackup_snapshot_helper test” wether there is a zfs ok, go to the web interface of urbackup and choose raw copy on write.
Install clients.

If you like to have the ability to start, stop and restart urbackup service you can install a start script:

nano /etc/rc.d/urbackupsrv

paste in the following:

#!/bin/sh
. /etc/rc.subr
name=urbackupsrv
rcvar=urbackupsrv_enable
command="/usr/local/bin/${name}"
command_args=“run -d -g 104857600 -u root”
start_precmd=“cd /usr/local/var”
load_rc_config $name
run_rc_command “$1”

than give executive permission:
chmod +x /etc/rc.d/urbackupsrv

Tell rc.conf to enable urbackupsrv via:

nano /etc/rc.conf

and put the line:

urbackupsrv_enable=“YES”

at the end.

I think it is better than starting urbackup via the jail-post-start script.
So if you use this, delete “jexec -U root urbackup /usr/local/bin/urbackupsrv run -d -g 104857600 -u root” in the post-start-script!

Just to be clear : i am a totaly noob in this and i surly break rules in freenas
or urbackup. The aspekt of security is not clear and so on…
But it is working for me by now.
I do not have any other jails on this machine so…
Any help is requested.

1 Like

Thanks for posting! Better then what I did. I compiled the urbackup server in the jail then copied it to the FreeNAS boot OS and ran it without jails (as root!). Idk if image mounting works with your method.