vz-clone: a nifty script to clone vz containers
The title says it all …
#!/bin/bash
# script to clone an openvz VEset -e
if [ -z "$2" ]; then
echo “Usage: $0 <veid> <new-id>”
exit 1
ficfg=”/etc/vz/conf/$1.conf”
newcfg=”/etc/vz/conf/$2.conf”if [ ! -e $cfg ]; then
echo $cfg not found!
exit 1
fiVEID=$1
. $cfg
veprivate=”$VE_PRIVATE”VEID=$2
. $cfg
newveprivate=”$VE_PRIVATE”if [ -e $newcfg ]; then
echo $newcfg already exists!
exit 1
fiif [ -e $newveprivate ]; then
echo $newveprivate already exists!
exit 1
fiif vzlist | fgrep -w -q $1
then
vzctl stop $1
fiecho “Cloning $cfg to $newcfg”
cp -a $cfg $newcfgecho “Cloning $veprivate to $newveprivate”
mkdir -p $newveprivate
cd $veprivate
tar cf – . | (cd $newveprivate && tar xf -)echo “Do not forget to edit $newcfg (you need to edit at least HOSTNAME and IP_ADDRESS)”
echo “Also do not forget to make an alias”
Source – http://www.howtoforge.com/some-tips-on-openvz-deployment
Posted on May 25, 2010, in thoughtpad and tagged clone, container, openvz, vz. Bookmark the permalink. Leave a Comment.
Leave a Comment
Comments (0)