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

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,813
    Thanks Received:
    2,462
    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.
     
    Xrsus thanks for this.
  4. Xrsus

    Xrsus New Member

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