LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > routers
User Name
Password

Notices


Rate this Entry

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:
Code:
root@sol-11:/export/zones# ls
bakzone.sh                    restzone.sh                                                                             
readme-backup                 sol-11dev
so i want to backup sol-11dev zone

Code:
root@sol-11:/export/zones# ./bakzone.sh sol-11dev $(pwd)
its create file.gz and to restore
Code:
root@sol-11:/export/zones# ./restzone.sh sol-11dev.Nov30_1533.cpio.gz
so the code is here

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
and the restzone.sh

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
origin: http://osdir.com/ml/solaris.opensola.../msg00142.html
i only change the path and gzip -f , w/o -f not work for me
Views 4022 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 11:19 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration