Solaris 11 Zone Backup
Posted 11-30-2012 at 05:13 AM by routers
need to have 2 file chmod 755
1) bakzone.sh <- use to backup
2) restzone.sh <- use to restore (verify line ZDIR )
the zone must be shutdown before run backup
take a look at the path in the scripts to suite the need. for me, all my zone in /export/zones/
so i place this 2 scripts in this folder , work perfectly
usage:
so i want to backup sol-11dev zone
its create file.gz and to restore
so the code is here
1) bakzone.sh
and the restzone.sh
origin: http://osdir.com/ml/solaris.opensola.../msg00142.html
i only change the path and gzip -f , w/o -f not work for me
1) bakzone.sh <- use to backup
2) restzone.sh <- use to restore (verify line ZDIR )
the zone must be shutdown before run backup
take a look at the path in the scripts to suite the need. for me, all my zone in /export/zones/
so i place this 2 scripts in this folder , work perfectly
usage:
Code:
root@sol-11:/export/zones# ls bakzone.sh restzone.sh readme-backup sol-11dev
Code:
root@sol-11:/export/zones# ./bakzone.sh sol-11dev $(pwd)
Code:
root@sol-11:/export/zones# ./restzone.sh sol-11dev.Nov30_1533.cpio.gz
1) bakzone.sh
Code:
# # bakzone.sh sol-11dev $(pwd) # # backup zone TIME=`date '+%b%d_%H%M'` # backup speed, -1 fast, -9 small, "" default BAKLVL="-1" 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 -f "$BAKLVL" >$BAKDIR/$1.$TIME.cpio.gz else date echo "Usage: bakzone.sh <zonename> <backup directory>" fi
Code:
# # restzone.sh file.cpio.gz # 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=/export/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
i only change the path and gzip -f , w/o -f not work for me
Total Comments 0