Michael Doran Home Page
Contact | Site Map | Search  
  Home > Archives > Using Scripts > bk-bull-dl0
This page is deprecated: please read archives disclaimer.

Using Scripts to Automate Voyager Tasks

bk-bull-dl0

Session File

#!/bin/sh

###################################################################
#
#   Shell Script: bk-bull-dl0
#
#   1998 & 1999, Michael Doran, doran@uta.edu
#   University of Texas at Arlington Libraries
#
#   Backup of Bullwinkle's non-Voyager file systems, dump level 0
#
###################################################################

# Variables:
 args=0ucf                        # Arguments to ufsdump
 mt_pt=/m1                        # File system mount point
 script_name=$0                   # Script name
 sess_file=/tmp/bklog.$$          # Session file
 tape_dev=/dev/rmt/0cbn           # Tape dev, w/ comprs; no rewind
 trash_can=/dev/null              # Unwanted output

# for "operator" see /etc/mail/aliases 

# Function to add comments to session file
add ()
{
    /usr/bin/echo "$1" >> ${sess_file}
}

# Function to mail session file to operator
swoosh ()
{
    /usr/bin/mailx -s "$1" operator < ${sess_file}
}

# Provide session file with script name and date
add "Script: ${script_name}\n`date`"
add "Backup of Bullwinkle's non-Voyager filesystems.\n"

# Check for tape:
/usr/bin/mt -f ${tape_dev} status >> ${trash_can} 2>&1
if [ $? -ne 0 ]     # If no tape
then                # notify operator and ...
    add "Backup aborted: No tape in drive."
    swoosh "Backup error"
    exit 1             # abort the backup.
fi 

# Do backup
for file_system in / /var /export/home
do
    /usr/sbin/ufsdump ${args} ${tape_dev} ${file_system} \
	>> ${sess_file} 2>&1
    # save ufsdump exit status
    dump_status=$?
    if [ ${dump_status} -ne 0 ]  # If dump is unsuccessful
    then
        # send dump status to session file...
        add "\\nDump problem: exit status = $dump_status"
        # mail session file to operator...
        swoosh "Backup Log with ERROR"
        # and exit the script.
        exit 1
    fi
done

# Send session file to operator...
add "\n${script_name} completed\\t`date`"
swoosh "Backup Log"

# and exit script.
exit 0