OpenVZ - Virtual Private Server

How to clone a OpenVZ Container

If you need to create an exact copy of an existing VE, these are the steps to make.

vzctl stop $OLDVE
mkdir /vz/root/$NEWVE
cp /etc/vz/conf/$OLDVE.conf /etc/vz/conf/$NEWVE.conf
mkdir /vz/private/$NEWVE
pushd /vz/private/$OLDVE
tar c –numeric-owner * | tar x –numeric-owner -C /vz/private/$NEWVE
vi /etc/vz/conf/$NEWVE.conf

Change the IP_ADDRESS

vzctl start $NEWVE; vzctl start $OLDVE

In case you are making bridge don’t forget, before start the VEs, to change host_ifname=veth$OLDVE by host_ifname=veth$NEWVE in the /etc/vz/conf/$NEWVE.conf file