How to migrate multiple jails? New system.

Status
Not open for further replies.

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I am close to finished testing new system, how do I migrate jails?
Bear in mind, the iocage export function will be broken until 11.2 U1 comes out, so I need another way of copying the jails across and creating the entries in the UI.

Can it be done?
 

garm

Wizard
Joined
Aug 19, 2017
Messages
1,556
Watching this, haven’t had time to try it out myself yet.
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
Without iocage export, you can try this (on a test system first hopefully):
I have not tested this out but I put this together from bits of information I read.

First lets snapshot the iocage dataset and store it in a file.

Code:
iocage stop all
zfs unmount -f oldvDev/iocage@OGHost
zfs send -R oldvDev/iocage@migrate > gzip /media/iocageBackup.gz



Take that file to a new system.
- The iocage activate command will create the new iocage dataset but not mount it.
- running iocage list for the first time should mount the dataset and create missing directories if any.

Code:
iocage activate newSysvDev
gzcat /media/iocageBackup.gz | zfs recv -F newSysvDev/iocage
zfs rollback newSysvDev/iocage@OGHost
iocage list


You will have to manually change fstab entries on the new system for all jails.
If this works you can also look into incremental zfs backups/snapshots so that the nextbackup file will be small and not the entire dataset.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Without iocage export, you can try this (on a test system first hopefully):
I have not tested this out but I put this together from bits of information I read.

First lets snapshot the iocage dataset and store it in a file.

Code:
iocage stop all
zfs unmount -f oldvDev/iocage@OGHost
zfs send -R oldvDev/iocage@migrate > gzip /media/iocageBackup.gz

Firstly, big thank you.
Secondly, I want to TEST this first,.......

So your 2'nd command there, to unmount the iocage data, how do I re-mount said data, on the main system again, incase it all fails?
(I'll leave all the plugins in a stopped state on the old system, to avoid duplicate IPs)


Take that file to a new system.
- The iocage activate command will create the new iocage dataset but not mount it.
- running iocage list for the first time should mount the dataset and create missing directories if any.

Code:
iocage activate newSysvDev
gzcat /media/iocageBackup.gz | zfs recv -F newSysvDev/iocage
zfs rollback newSysvDev/iocage@OGHost
iocage list


You will have to manually change fstab entries on the new system for all jails.
If this works you can also look into incremental zfs backups/snapshots so that the nextbackup file will be small and not the entire dataset.


Will this xfer include all the elements of the jail, even down to the mac address that is bound to the pretend adaptor (therefore, DHCP may well offer these jails, the same DHCP static IPs (if set on router, not just hardcoded into the jail?)

Thanks again.

So sad that export = dead until 11.2 U1 or U2 - but at least I found yet another bug, this time bigger than FreeNAS :)
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Code:
iocage stop all
zfs unmount -f oldvDev/iocage@OGHost
zfs send -R oldvDev/iocage@migrate > gzip /media/iocageBackup.gz


Ok so I tried on my test machines, got an error unfortunately (see below)
What do you think?



Code:
root@freenas:/mnt/POOLNAME # zfs send -R /mnt/POOLNAME/iocage > gzip /mnt/POOLNAME/media/iocageBackup.gz
too many arguments
usage:
		send [-DnPpRvLec] [-[iI] snapshot] <snapshot>
		send [-Le] [-i snapshot|bookmark] <filesystem|volume|snapshot>
		send [-nvPe] -t <receive_resume_token>

For the property list, run: zfs set|get

For the delegated permission list, run: zfs allow|unallow

 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
So your 2'nd command there, to unmount the iocage data, how do I re-mount said data, on the main system again, in case it all fails?

zfs mount oldvDev/iocage

Will this xfer include all the elements of the jail, even down to the mac address that is bound to the pretend adaptor (therefore, DHCP may well offer these jails, the same DHCP static IPs (if set on router, not just hardcoded into the jail?)
Yep, should be the exact same.

zfs send -R /mnt/POOLNAME/iocage > gzip /mnt/POOLNAME/media/iocageBackup.gz
too many arguments

Using the zfs command we are trying to put a dataset in a file, you cannot use the path of the "folder". You must use the zfs dataset name.
Use zfs list to see all your datasets. I think it would be zfs send -R poolname/iocage for you.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Using the zfs command we are trying to put a dataset in a file, you cannot use the path of the "folder". You must use the zfs dataset name.
Use zfs list to see all your datasets. I think it would be zfs send -R poolname/iocage for you.


Still issues, I think? Maybe the gzip and the -R is or isn't needed?

Code:
root@freenas:/mnt/POOLNAME # zfs send POOLNAME/iocage
Error: Stream can not be written to a terminal.
You must redirect standard output.
root@freenas:/mnt/POOLNAME # zfs send POOLNAME/iocage >  /mnt/POOLNAME/media/iocageBackup.gz
root@freenas:/mnt/POOLNAME # ls /mnt/POOLNAME/
gzip	iocage/ media/
root@freenas:/mnt/POOLNAME # ls -l /mnt/POOLNAME/media/
total 3045
-rw-r--r--  1 root  wheel  3464752 Nov 28 07:30 iocageBackup.gz
root@freenas:/mnt/POOLNAME # zfs send -R POOLNAME/iocage > /mnt/POOLNAME/media/iocageBackup.gz
Error: Unsupported flag with filesystem or bookmark.
root@freenas:/mnt/POOLNAME # zfs send -R POOLNAME/iocage > gzip /mnt/POOLNAME/media/iocageBackup.gz
too many arguments
usage:
		send [-DnPpRvLec] [-[iI] snapshot] <snapshot>
		send [-Le] [-i snapshot|bookmark] <filesystem|volume|snapshot>
		send [-nvPe] -t <receive_resume_token>

For the property list, run: zfs set|get

For the delegated permission list, run: zfs allow|unallow
root@freenas:/mnt/POOLNAME # zfs send -R POOLNAME/iocage > /mnt/POOLNAME/media/iocageBackup.gz
Error: Unsupported flag with filesystem or bookmark.
root@freenas:/mnt/POOLNAME # zfs send POOLNAME/iocage > /mnt/POOLNAME/media/iocageBackup.gz
root@freenas:/mnt/POOLNAME # zfs send -R POOLNAME/iocage > /mnt/POOLNAME/media/iocageBackup.gz
Error: Unsupported flag with filesystem or bookmark.
root@freenas:/mnt/POOLNAME #



I messed around and did end up getting it to dump a file, without the gzip, you think that file is suitable?
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
Still issues, I think? Maybe the gzip and the -R is or isn't needed?

I messed around and did end up getting it to dump a file, without the gzip, you think that file is suitable?

To be honest im not sure. Like I said I have not tried it cause none of my jails use _, so i just use export.
The dump file should be usable, thats a perfectly valid backup.
I put this info from bit and pieces, I read somewhere @danb35 saying you could dump it to a file, but im not sure what the command is to restore it.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I'm still having some difficulty. Can't import the file as it's not a real gzip (which makes sense, I didn't > to gzip, if you recall in my log there, the entry WITHOUT the gzip command, is the one which works)

So I'm not entirely sure of the contents of the gz file I have - just a raw ZFS dump - how do I import that?


Code:
root@freenasnew[/mnt/SSD/TESTSSD]# gzcat iocageBackup.gz | zfs recv -F SSD/iocage
gzcat: iocageBackup.gz: not in gzip format
cannot receive: failed to read from stream

 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
You know, what I didn't think of.

Is the iocage rename function working properly - I could've sworn I found a bug in it, in BETA3- maybe, I can't recall?
For some reason I disqualified it as an option.

I just tried it in test on RC2 and I can confirm that not only does it rename a jail, if the jail is a plugin, FreeNAS 11.2 RC2 will recognise the jail being renamed and update the UI reference for the plugin to jail correctly (nice!)

So I've just renamed ALL my jails on my main machine, from _1 or _2 to just 1 or 2 etc.
Now to try the import / export process. Very cool.
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
^Lol well glad you got export and import to work, its the better option by far.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I found bugs (of course!) but yeah, this is working half decent.

I'm 2/3 done with the new server, I've never been so thorough setting up a system before, including for work!
 

pschatz100

Guru
Joined
Mar 30, 2014
Messages
1,184
Are you migrating old iocage jails to newer ones? Why?

Over the weekend, I updated FreeNAS from 11.1-U6 to 11.2-RC2. All my manual jails continued to work just fine (some of them go way back to early versions of 11.1).

As an exta test, I tried updating one jail from 11.1 to 11.2 using the GUI, and that worked OK. I'm not running any VM's so I can't comment about that, but my jails are doing fine.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Are you migrating old iocage jails to newer ones? Why?

Over the weekend, I updated FreeNAS from 11.1-U6 to 11.2-RC2. All my manual jails continued to work just fine (some of them go way back to early versions of 11.1).

As an exta test, I tried updating one jail from 11.1 to 11.2 using the GUI, and that worked OK. I'm not running any VM's so I can't comment about that, but my jails are doing fine.

I'm switching from a 7 year old, 2 core machine with 16GB to an 8 core machine with 32GB - I also have a bit more drive space, 10GB networking, IPMI etc - plus it uses about 15 / 20W less power to boot.
 

pschatz100

Guru
Joined
Mar 30, 2014
Messages
1,184
I thought the original post was about migrating iocage jails. Did I miss something?
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Different type of migrating.

We're migrating from one system to another (FreeNAS Server)
Not the current migrating that's very important, from 11.1 (and earlier) into 11.2 - an entirely different "jail engine" under the hood (same server)

I'm literally exporting a jail from a server, importing on another so I don't have to reconfigure it, hope that makes sense.
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
Also his jails had names like plex_1,sonarr_2 etc and right now iocage export / import is broken if you use an underscore, so he/she wanted an another way.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I've written the script I always wanted for backups now as a bonus! it's basic but it works.


Code:
# Stop all jails
#

#iocage stop plex
iocage stop couchpotato
iocage stop jackett
#iocage stop qbittorrent
iocage stop qbittorrent1
iocage stop qbittorrent2
iocage stop radarr
iocage stop sabnzbd2
iocage stop sickchill
iocage stop smokeping

# Export all jails
#


#iocage export plex
iocage export couchpotato
iocage export jackett
#iocage export qbittorrent
iocage export qbittorrent1
iocage export qbittorrent2
iocage export radarr
iocage export sabnzbd2
iocage export sickchill
iocage export smokeping


# Start (most likely) running jails
#


#iocage start plex
#iocage start couchpotato
iocage start jackett
#iocage start qbittorrent
iocage start qbittorrent1
#iocage start qbittorrent2
iocage start radarr
#iocage start sabnzbd2
iocage start sickchill
iocage start smokeping


# Copy the exported jails into the backups folder.
cp /mnt/SSD/iocage/images/*.* /mnt/ARRAY/data/backup/jails




 
Status
Not open for further replies.
Top