Michael Doran Home Page
Contact | Site Map | Search  
  Home > Archives > Using Scripts > Reading & Writing > Ex. #2: bk-vygr-dl0 3
Using Scripts to Automate Voyager Tasks

Example #2: bk-vygr-dl0 1 2 3 4


#!/bin/sh

###############################################################
#
#   Shell Script: bk-vygr-dl0
#   Backup Voyager database, dump level 0
#   1998 & 1999, Michael Doran, doran@uta.edu
#   University of Texas at Arlington Libraries
#
###############################################################

# Variables:
 args=0ucvf                       # Arguments to ufsdump
 mt_pt=/m1                        # File system mount point
 script_name=$0                   # Script name
 tape_dev=/dev/rmt/0cb            # Tape device, w/ compression

# Check for tape:
/usr/bin/mt -f ${tape_dev} status
if [ $? -ne 0 ]     # If no tape
then
    exit 1          # abort the backup.
fi 

# shut down servers
/etc/init.d/dbora stop
/etc/init.d/httpd stop

# run "savecritical" script (per Voyager Technical Manual)
/m1/utility/savecritical

# Unmount the Voyager file system
/usr/sbin/umount ${mt_pt}
if [ $? -ne 0 ]   # If not successful
then
    # kill processes that are using Voyager resources
    /usr/sbin/fuser -c -k ${mt_pt}
    # and try again to unmount
    /usr/sbin/umount ${mt_pt}
    # If it still won't unmount...
    if [ $? -ne 0 ]
    then
        # restart the Voyager and Web Servers, ...
	/etc/init.d/dbora start
	/etc/init.d/httpd start
	/etc/init.d/voyager start
        # abort the backup.
        exit 1
    fi
fi

# Do backup
/usr/sbin/ufsdump ${args} ${tape_dev} /dev/md/rdsk/d0

# Remount the Voyager file system
/usr/sbin/mount ${mt_pt}
# Did the Voyager file system remount?
if [ $? -ne 0 ]  # If not...
then
    # reboot system.
    /usr/sbin/init 6
    exit 1
else  # If yes...
    # restart the Voyager and Web servers.
    /etc/init.d/dbora start
    /etc/init.d/httpd start
    /etc/init.d/voyager start
    # Did Voyager restart?
    if [ $? -ne 0 ]
    # If not...
    then
        # reboot system.
        /usr/sbin/init 6
        exit 1
    fi
fi

# and exit script.
exit 0