Here's a backup and restore script that we developed and used many many times, 
however, for legal purposes I must say, "test and use at your own risk."  
Scripts must be ran from the global zone.

ex.  bakzone.sh <zonename> <backup directory>
ex.  restzone.sh <backup file created by bakzone.sh>

Note 1.  restore script must be ran while in the backup dir
Note 2.  restore script assumes zones will be restored in /zones
Note 3.  zones must be shutdown but mounted if using remote storage

----- bakzone.sh ---------------------------
#
# bakzone.sh
#
# backup zone

TIME=`date '+%b%d_%H%M'`
# backup speed, -1 fast, -9 small, "" default
BAKLVL="-5"

if [ -n "$1" -a -f /etc/zones/$1.xml -a -d "$2" ]
then
ZONE=$1
BAKDIR=$2

ZP=`zonecfg -z $1 info zonepath|awk '{print $2}'`
echo "Backing up $ZONE:$ZP"
date
find /etc/zones/$ZONE.xml $ZP -print |egrep -v '(/root/proc/|/root/tmp/)' | 
cpio -ocC 262144  2>$BAKDIR/$1.$TIME.log | time gzip "$BAKLVL" 
>$BAKDIR/$1.$TIME.cpio.gz
else
date
echo "Usage: bakzone.sh <zonename> <backup directory>"
fi

----- restzone.sh ---------------------------
#
# restzone.sh
#

if [ -n "$1" -a -f "$1" ]
then
BAKDIR=`pwd`
ZONE=`echo $1|cut -f1 -d\.`
echo "Restoring zone $ZONE ..."
date
cd /
time gzip -dc $BAKDIR/$1 | cpio -icdumC 262144
RES=$?
date
if [ "$RES" -eq 0 ]
then
ZDIR=/zones/$ZONE

if ! grep "^$ZONE:" /etc/zones/index >/dev/null
then
echo "$ZONE:installed:$ZDIR" >>/etc/zones/index
fi

fi
else
echo "Backup file $1 not found!"
fi
 
 
This message posted from opensolaris.org
_______________________________________________
zones-discuss mailing list
zones-discuss@opensolaris.org

Reply via email to