Auto-Backing Up Jails

Dellyjoe

Explorer
Joined
Jun 12, 2020
Messages
80
Hello everyone,

I'm not sure if this is the right word I'm new to Freenas and nas in general. However I was listening to a Podcast self-hosted and they were talking about taking a snap shot of a container which I would think just means taking a snap shot of a jail. They then package it up some how and put it on there private github, so if they had to delete it for some reason or it broke then can build a new one in minutes.

Does anyone know how to start the process in doing this. I really just want to back-up my nextcloud sever, and maybe my plex sever. Just the jails not the external data that is storage in them.

Thank you for reading,
Joe
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
No, the podcast was talking about snapshots of Docker containers, which is a different technology from jails.

You can snapshot jails by just clicking the Update button beneath the jail:

1596799405417.png


You can also automate this via Tasks->Cron Jobs by running iocage snapshot <name of jail> on a periodic basis. To restore to a previous snapshot, run iocage rollback -n <name of snapshot> <name of jail>. Run iocage snaplist <name of jail>.

To generate a TAR archive of a jail, stop the jail, and run iocage export <name of jail>; this will create a TAR image of the jail in /mnt/<pool name>/iocage/images you can then copy off-site. To restore from the TAR image, run iocage import <name of jail>, without the TAR extension.
 

Dellyjoe

Explorer
Joined
Jun 12, 2020
Messages
80
No, the podcast was talking about snapshots of Docker containers, which is a different technology from jails.

You can snapshot jails by just clicking the Update button beneath the jail:

View attachment 40628

You can also automate this via Tasks->Cron Jobs by running iocage snapshot <name of jail> on a periodic basis. To restore to a previous snapshot, run iocage rollback -n <name of snapshot> <name of jail>. Run iocage snaplist <name of jail>.

To generate a TAR archive of a jail, stop the jail, and run iocage export <name of jail>; this will create a TAR image of the jail in /mnt/<pool name>/iocage/images you can then copy off-site. To restore from the TAR image, run iocage import <name of jail>, without the TAR extension.

Thank you for getting back to me in a short amount of time. My understanding of what a snapshot is was completely wrong, thank you for helping me correct my local definition of a snapshot.

The picture that you linked is a little confusing to me. You state you can snapshot a jail by just hitting the update button. To confirm when doing this do you create a backup and then update your jail. or are you just checking for an update and then update the jail?

You also state something I haven't heard of before a TAR. I think this is what I'm truly looking for. I believe I will learn how to make a TAR and then have that backup on a cloud based storage system or maybe a private gethub and then I can figure out how to create a clone job that will allow me to download the jail and run it like it is currently on my system if anything goes wrong.

Again thank you for getting back to me, this is a good starting point for me. To start to research what I need to do for my current Idea.

Joe
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
The update button automatically creates a snapshot before applying the update. If no update exists, it still creates a snapshot.
 

Dellyjoe

Explorer
Joined
Jun 12, 2020
Messages
80
The update button automatically creates a snapshot before applying the update. If no update exists, it still creates a snapshot.
got ya understood.

When running the command, iocage export <name of jail> I ended up creating a backup with .zip which when moving it over to my windows computer i found it starts from mnt/Tank1/iocage/images/and then it has the name of the jail and another with the same name but with root at the end.

My question is, why does it create the backup from mnt?

This brings up the questions, when I'm trying to just backup the jail and a plugin, so later down the road If I wipe everything or more to a new computer I don't have to rename the Tanks the same and have everything in the same place. I can just unzip the folder in a jail location I set up.

Is the TAR command you wrote above the best way to do this?

Let me know what you think,
Joe
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
When running the command, iocage export <name of jail> I ended up creating a backup with .zip which when moving it over to my windows computer i found it starts from mnt/Tank1/iocage/images/and then it has the name of the jail and another with the same name but with root at the end.

My question is, why does it create the backup from mnt?

That's just how iocage works. The jail is built as a dataset under /mnt/<name of pool>/iocage/jails/<name of jail>/root, and this is actually a set of nested ZFS datasets. The innermost dataset is root, and contains the file system inside the jail. The next-outermost dataset is the name of the jail, and is how iocage stores the jail's attributes.

This brings up the questions, when I'm trying to just backup the jail and a plugin, so later down the road If I wipe everything or more to a new computer I don't have to rename the Tanks the same and have everything in the same place. I can just unzip the folder in a jail location I set up.

No, you don't need to manually unzip. iocage import <name of jail> takes care of that for you, adjusting for the change in pool names.

I must admit to being mistaken earlier the export would result in a TAR file, as I was going by the iocage man page.
 

Dellyjoe

Explorer
Joined
Jun 12, 2020
Messages
80
That's just how iocage works. The jail is built as a dataset under /mnt/<name of pool>/iocage/jails/<name of jail>/root, and this is actually a set of nested ZFS datasets. The innermost dataset is root, and contains the file system inside the jail. The next-outermost dataset is the name of the jail, and is how iocage stores the jail's attributes.



No, you don't need to manually unzip. iocage import <name of jail> takes care of that for you, adjusting for the change in pool names.

I must admit to being mistaken earlier the export would result in a TAR file, as I was going by the iocage man page.

so when you stated adjusting for the change in pool names, that means if I make a pool name of example in my new sever and run the command iocage import <name of jail> it will still import the jail under that new pool mnt/example/iocage ??

Sorry I'm new to this, just trying to rap my head around everything.

Joe
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
so when you stated adjusting for the change in pool names, that means if I make a pool name of example in my new sever and run the command iocage import <name of jail> it will still import the jail under that new pool mnt/example/iocage ??

I believe so, yes.
 

StanTheMa

Dabbler
Joined
Jun 30, 2020
Messages
13
Hi Joe and Samuel
I was tidying up my NAS discovered lots of failing jailimageing.sh tasks (there isnt such a script on my NAS!). I was searching the forums as I believed it must be something I discovered here and search led me here. Just a thought I discovered I can delete my old remnant task as I have replaced it using the GUI.

This may help Joe in the future.
In the GUI I set up Task> Periodic Snapshots, and also Tasks > Replications. I believe these automate the work your doing above (I have things like Nextcloud config on ssd backing up to PoolMyZFS (spinning WDiscs). With main iocage jails replicating to the ssd pair.
I include GUI pics.
For most critical parts I have rsync job to copy to Win Pc disk, and copies from the SMB win share dataset to a MS OneDrive account using GUI Tasks> Cloud Sync.
Samuel thanks your info on iocage export / import to new discs was a good reminder.

Cheers Bernie
NASreplicateTasksFortnightly2021-07-26.png
NAStasksSnapshotsdaily2021-07-26.png
NASpools22021-07-26.png
NASpools1 2021-07-26.png
 

Jonathan .

Dabbler
Joined
Sep 22, 2020
Messages
17
No, the podcast was talking about snapshots of Docker containers, which is a different technology from jails.

You can snapshot jails by just clicking the Update button beneath the jail:

View attachment 40628

You can also automate this via Tasks->Cron Jobs by running iocage snapshot <name of jail> on a periodic basis. To restore to a previous snapshot, run iocage rollback -n <name of snapshot> <name of jail>. Run iocage snaplist <name of jail>.

To generate a TAR archive of a jail, stop the jail, and run iocage export <name of jail>; this will create a TAR image of the jail in /mnt/<pool name>/iocage/images you can then copy off-site. To restore from the TAR image, run iocage import <name of jail>, without the TAR extension.
Thank you so much I have been trying to fix a fuckup of an update with my nextcloud and this saved me thank you, thank you, thank you. So many pages on the forum just tell you to do things without explaining how presuming you know and whenever someone asks they never get a good response. Thank you.
 
Top