1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Transferring a Jail

Discussion in 'General' started by Xrsus, Sep 16, 2010.

  1. Xrsus

    Xrsus New Member

    Messages:
    12
    Thanks Received:
    0
    I have FreeBSD set up on multiple machines, and I am looking for advice on the best way to transfer a jail from one system to another.

    Essentially, system A with the jails on it now, is running 7.2, and the 3 jails are also running a full 7.2. They are located in /usr/jail/cell01, /usr/jail/cell02, and /usr/jail/cell03 respectively.

    I have system B running 7.2 as well.

    I realize I'm going to have to change IP information in the main server for starting the jails, and of course configuration files within the jails themselves once they are running. What is the best way to transfer these full jail environments over to the new system? Is it as simple as tar-ing the whole jail folder structure for each jail, copying it over, and then starting it?

    Thanks in advance for any help, and I don't mind doing further reading either if someone can post links to such required reading. :)
     
  2. danbi

    danbi New Member

    Messages:
    227
    Thanks Received:
    27
    You could also use rsync, to copy the jail's filesystems over. This way, you will copy the bulk of the data while the jail is running, and can copy the changed data via rsync while the jail is down, thus minimizing downtime.

    If you use the FreeBSD jail infrastructure (via rc.conf) then you need to copy the jail configuration to the new system, shutdown jail in the old system, remove IP address from the old system, assign the IP address to the new host and start the jail there.

    This assumes kernels etc are the same.
     
    Xrsus thanks for this.
  3. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,917
    Thanks Received:
    2,517
    Doing it by hand, log in on the remote system and do this as root:
    # ssh user@first.system tar -C /usr/jail -cf - cell01 | tar -C /usr/jail -xvf -

    You can't just use scp or similar because that will wreck hard and softlinks.
     
    robroy and Xrsus thanked for this.
  4. Xrsus

    Xrsus New Member

    Messages:
    12
    Thanks Received:
    0
    Thank you for the quick info! Moderator, please mark this as solved.
     
  5. nforced

    nforced New Member

    Messages:
    44
    Thanks Received:
    2
    I know this topic is old but I come across while looking for the same, so here is one other solution I tried and it works for me, refer: https://www.freebsd.org/doc/en/books/handbook/jails-ezjail.html and http://www.bsdnow.tv/tutorials/jails
    Code:
    You can easily move jails between hosts with minimal configuration changes. Let's stop our example jail and archive it to a file.
    # ezjail-admin stop bsdnow.tv
    # ezjail-admin archive bsdnow.tv
    
    The archived file should appear in /usr/jails/ezjail_archives. You can securely transfer the file to another server, make a new basejail and put the archive in place.
    # ezjail-admin create -a /usr/jails/ezjail_archives/bsdnow_tv.tar.gz bsdnow.tv 192.168.1.13
    # ezjail-admin start bsdnow.tv