I just installed iocage via pkg install py36-iocage and made a test jail. I would like to backup that jail, and then restore it on a different computer. Is that possible?.. If it is, what would be the best way to go about doing that?
iocage export UUID | NAME
Exports the specified jail. An archive file is created in
/iocage/images with an SHA256 checksum. The jail must be
stopped before exporting.
Example: # iocage export examplejail_2
iocage import UUID | NAME
Import a specific jail image. Short UUIDs can be used, but
do not specify the full filename, only the UUID.
EDIT: only the UUID <-- This is incorrect
You can specify iocage jail name to import
Example: # iocage import 064c247 <-- incorrect Example: # iocage import myjail <-- this works fine
I think that the man page for iocage doesn’t reflect changes in py36-iocage version.
Secondly, my experiments with exporting/importing jails with py36-iocage were done within existing iocage ZFS data set. I don’t know how the iocage import would behave if you transfer the exported iocage jail’s zip file to another system that also runs py36-iocage.
Luckily it’s a test jail… After testing, I want to move that jail to a production server, and would also like to have a recovery plan, in case I need to move it to another server if/when this one fails.
Thank you for all the help and the tips to get me started in the right direction @ichibiri , I will start experimenting with this.
I tried it yesterday, and it worked fine when transferred to another (TrueOS) system. It even makes the datasets for the jail, the only problem is that the datasets it makes are blank… I thought I could just import jail, and it would bring all the information with it apparently I was wrong. I had to import the jail, delete the empty dataset it made, and, then zfs receive to the host computer, then all my data was back in the jail.
Don’t understand what you mean by “empty dataset it made”
The ZFS dataset is /iocage in your ZPOOL name (tank, root, ztank or ??)
iocage import doesn’t create new data set. It restores root system dir. in /iocage/jails of the imported jail along with fstab and config.json
I did quick install of TureOS in another old box. I copied myjail.zp and myjail.sha256 to /iocage/images dir. The iocage import worked just fine.
“iocage import myjail” from /iocage/images/myjail.zip
“iocage start my jail” all came back alive as expected
All above is related to how I do iocage, in general.
- iocage activate ZPOOL (your zpool name) <-- this creates automagically the /iocage ZFS data set dir.
- iocage fetch -r 11.1-RELEASE (or whatever FreeBSD release you wish for that will match your exported myjail)
- iocage import myjail - from /iocage/images dir.
To create new jail and export
iocage create -n myjail ip4_addr=“bge0|192.168.1.10/24” -r 11.1-RELEASE
iocage export myjail - it will be exported to /iocage/images dir by iocage
If you want to avoid setting things with “iocage set” you can edit “config.json” file, in jail’s dir.
I used zfs create inside the jail to create a new dataset, and moved it to a differen machine. I didn’t realize that the dataset was there, I just needed to mount it.
TrueOS becoming a core OS