#!/bin/ksh # # Simple backup script for a list of volume groups. All filesystems # in each of the volume groups specified will be backed up using the # "backup" command. # # Andy Welter # www.the-welters.com # February 17, 1999 # # parms: # -log If this parm is used, script output will be logged to # /var/adm/logs/backup.YYMMDD.log. Otherwise script output # will be written to the screen. # A list of additional volume groups to backup. If not present, the # The script defaults to backing up "rootvg" only. # DEV=/dev/rmt0.1 PRINT="" while [ "$1" != "" ]; do case $1 in "-log") # Redirect output to the log file LOG=`date +"/var/adm/logs/backup.%y%m%d.log"` exec 2> $LOG >&2 ;; "-print") PRINT="yes" ;; *) VGLIST="$VGLIST $1" esac shift done if [ "$VGLIST" = "" ]; then VGLIST="" fi # Get list of mount points for VG in $VGLIST; do lsvg -l $VG | grep " jfs " | \ while read LV junk2 junk3 junk4 junk5 junk6 FS; do FSLIST="$FSLIST $FS" done done if [ "$FSLIST" = "" ]; then echo "NOTE: No extra file systems specified." echo "NOTE: Only rootvg will be backed up." fi RC=0 date +"begin backup at %y/%m/%d %H:%M" echo "Performing a mksysb and backing up the following file systems: $FSLIST" echo "Run mksysb..." mkszfile && mksysb -m -i -X $DEV RC2=$? RC=`expr $RC + $RC2` date +"mksysb complete at %y%m%d %H:%M" for FS in $FSLIST; do date +"backup $FS %y/%m/%d %H:%M" /etc/backup -0 -f $DEV $FS RC2=$? RC=`expr $RC + $RC2` if [ $RC -eq 0 ]; then echo "SUCCESS: done with $FS" else echo "ERROR: Backup of $FS failed" fi echo done # eject the tape if [ $RC -eq 0 ]; then echo "ejecting the tape..." mt -f $DEV offline else echo "ERROR: at least one backup had errors." fi date +"done with backup at %y/%m/%d %H:%M" if [ "$PRINT" = "yes" ]; then lp $LOG fi