Backing up ZFS dataset from within a jail

ilium007

Explorer
Joined
Apr 9, 2012
Messages
61
I have spent a few hours trying to get this to work. I want to run my Duplicacy backups from within a jail so that I can install the duplicacy binary and modify periodic jobs from with within the jail.

Can I access the FreeNAS ZFS datasets from within the jail without affecting the FreeNAS shares?

I want to be able to run a zfs snapshot from within the jail, mount that snapshot, run the duplicacy backup and unmount and delete the zfs snapshot.
 

garm

Wizard
Joined
Aug 19, 2017
Messages
1,556
Not directly. You can write a script that you run on FreeNAS with cron. Have the script take the snapshot and mount it for the jail, then iocage exec <jail> <command> to run the backup job from within the jail.
 

ilium007

Explorer
Joined
Apr 9, 2012
Messages
61
Not directly. You can write a script that you run on FreeNAS with cron. Have the script take the snapshot and mount it for the jail, then iocage exec <jail> <command> to run the backup job from within the jail.
Can I mount storage to a running jail or will I need to stop/start the jail each time?
 

garm

Wizard
Joined
Aug 19, 2017
Messages
1,556
I haven’t tried as I run my backups the other way, but I think you should be able to mount a folder to the jail and then mount the snapshot in that folder with the script. Messing with fstab for each backup job might be a source of issues
 

ilium007

Explorer
Joined
Apr 9, 2012
Messages
61
I have found that I can mount and unmount storage into a jail successfully but I am now stuck in finding a way to complete these backups.

I am using Duplicacy from the command line. The basic steps are as follows:
  • snapshot the ZFS dataset
  • mount the snapshot
  • run the duplicacy backup
  • unmount snapshot
  • prune local ZFS snapshots
Out of these steps, only 1 would run from the jail - running duplicacy backup. Given this, would it be advisable to run the backup from the Freenas O/S instead?

Duplicacy stores the chuck metadata locally so this would all be stored within the root home, this is the downside to doing to this way. If I could run the snapshot from *within* the jail I could keep it all contained.
 

garm

Wizard
Joined
Aug 19, 2017
Messages
1,556
Snapshots and other ZFS actions need to be done from FreeNAS. Keep the script in a dedicated dataset but execute it from /root, you can perform actions in the jail with iocage exec <jailname> <command>
 

ilium007

Explorer
Joined
Apr 9, 2012
Messages
61
Snapshots and other ZFS actions need to be done from FreeNAS. Keep the script in a dedicated dataset but execute it from /root, you can perform actions in the jail with iocage exec <jailname> <command>
What do you mean by 'execute it from /root? I know how to run jail commands from FreeNAS, that's not my problem. My issue is with limiting how much is done from FreeNAS vs the jail.
 

garm

Wizard
Joined
Aug 19, 2017
Messages
1,556
I would say best practice is setting up cron to run backup from FreeNAS and have it trigger the job inside the jail.
 
Top