#!/bin/ksh # Author: David Morris # Version: $Id: fullbackup,v 1.1 2004/11/05 20:58:17 davey Exp $ # Purpose: Try and backup any UFS or VXFS filesystems in a vfstab # License: Released under the GNU Public Licence (GPL) # The terms of the GPL are available at: # http://www.gnu.org/licenses/gpl.html export VFSTabFile=/etc/vfstab export FSTypes='ufs vxfs' export NRBackupDevice=/dev/rmt/0n export TAPE=/dev/rmt/0 export StartTime=$(date) echo "INFO: Backup Commenced: $StartTime" # Parse the vfstab file to get the tasty bits function ParseVFSTab { if [ -f $VFSTabFile ]; then for i in $FSTypes do /usr/bin/awk '$4 == "'$i'"' $VFSTabFile | /usr/bin/grep -v "^#" | /usr/bin/awk '{print $1 " " $2 " " $3 " " $4}' done fi } # Check and rewind the tape device function CheckTape { mt -f $TAPE status TapeRetCode=$? if [ $TapeRetCode -eq 0 ]; then mt -f $TAPE rewind continue else echo "ERROR: cannot get tape status error number: $TapeRetCode" exit fi } #Process the output of ParseVFSTab and run backups function ProcessVFSTab { export Count=0 while read dev rawdev mpoint fstype do print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" print "INFO: Backing up ${dev##*/}" print "Char Device: $dev" print "Raw Device: $rawdev" print "Mount Point: $mpoint" print "File System type: $fstype" print "Count: $Count" print "Tape control command to reach this record: mt fsf $Count" case $fstype in vxfs) DumpCmd="/usr/lib/fs/vxfs/vxdump -f $NRBackupDevice $rawdev" echo INFO: $DumpCmd $DumpCmd Retcode=$? if [ $Retcode -eq 0 ]; then echo "INFO: Backup of filesytem $rawdev completed" else echo "ERROR: Backup of $rawdev failed with return code $Retcode" fi ;; ufs) DumpCmd="/usr/sbin/ufsdump 0cfu $NRBackupDevice $rawdev" echo INFO: $DumpCmd $DumpCmd Retcode=$? if [ $Retcode -eq 0 ]; then echo "INFO: Backup of filesytem $rawdev completed" else echo "ERROR: Backup of $rawdev failed with return code $Retcode" fi ;; *) continue ;; esac ((Count+=1)) done print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } CheckTape ParseVFSTab | ProcessVFSTab export EndTime=$(date) echo "INFO: Backup Completed: $EndTime"