Home Contact
Validate the HTML of this page

Voyager ufsdump Script

bk-vygr-dl0

Session File
#!/bin/sh

###############################################################
#
#   Shell Script: bk-vygr-dl0
#
#   1998, 1999, 2000, 2005
#   Michael Doran, doran@uta.edu
#   University of Texas at Arlington Libraries
#
#   Backup Voyager database, dump level 0
#
#   Modified for fssnap
#   see man pages for fssnap and fssnap_ufs
#
###############################################################

# Variables:
 args=0ucf    # Arguments to ufsdump
              #  0 - dump level (full) 
              #  c - cartridge 
              #  f - filesystem 
              #  u - update dump record (note: dump date, not
              #      snapshot date) 
              #  v - verify (turned off, since uncertain of
              #      impact when using UFS snapshot)
 tape_dev=/dev/rmt/0cb               # Tape device, w/ compression
 script_name=$0                      # Script name
 sess_file=/tmp/bklog.$$             # Session file
 trash_can=/dev/null                 # Unwanted output
 file_sys=/m1                        # Voyager file system
 bs_dir=/scratch                     # Backing store directory
 bs_file=${bs_dir}${file_sys}-bsf    # Backing store file

# Function to mail error messages
senderr ()
{
    /usr/bin/echo "$1" | mailx -s "$0 error" root
}

# Function to start and stop Voyager servers
servers ()
{
  case "$1" in
  'start')
        /etc/init.d/dbora $1   >> ${trash_can} 2>&1
        /etc/init.d/voyager $1 >> ${trash_can} 2>&1
        /etc/init.d/httpd $1   >> ${trash_can} 2>&1
        ;;
  'stop')
        ps -ef | grep "LOCAL=NO" | grep -v grep >> ${trash_can} 2>&1
        if [ $? -eq 0 ]
        then
            echo "ps -ef | grep LOCAL=NO | grep -v grep"
            echo "`ps -ef | grep LOCAL=NO | grep -v grep`"
            kill -9 `ps -ef | grep "LOCAL=NO" | grep -v grep \
                        | /usr/bin/awk '{print $2}'`
        fi
        /etc/init.d/httpd $1   >> ${trash_can} 2>&1
        /etc/init.d/voyager $1 >> ${trash_can} 2>&1
        /etc/init.d/dbora $1   >> ${trash_can} 2>&1
        ;;
   *)
        echo "Usage: servers {start|stop}"
        ;;
  esac
}

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

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

# Function to send pager message to sysdamin
beepsysadmin ()
{
    /usr/bin/echo "$1" | /usr/bin/mailx -s "$1" beep-doran
}

# Provide session file with script name and date
add "Script: ${script_name}\n`date`"
add "Full backup of Voyager database.\n"

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

# shut Voyager down
servers stop

# run "savecritical" script (per Voyager Technical Manual)
/m1/utility/savecritical >> ${trash_can} 2>&1

# Create UFS snapshot
add "\nCreating snapshot..."
raw_snap_dev=`/usr/sbin/fssnap -F ufs \
 -o raw,unlink,backing-store=${bs_file} ${file_sys}` >> ${sess_file} 2>&1
if [ $? -ne 0 ]  # If fssnap had problems 
then
    beepsysadmin "`uname -n` backup problem: fssnap"
fi

add "\n${file_sys} being backed up via snapshot on ${raw_snap_dev}"
# For now, let's include this info in session file...
add "\nUFS Snapshot information..."
#/usr/lib/fs/ufs/fssnap -i ${file_sys} >> ${sess_file} 2>&1
/usr/lib/fs/ufs/fssnap -i >> ${sess_file} 2>&1

add "\n"

# start Voyager back up
servers start

# Do backup
if [ ${raw_snap_dev} ]
then
    /usr/sbin/ufsdump ${args} ${tape_dev} ${raw_snap_dev} \
	>> ${sess_file} 2>&1
    if [ $? -ne 0 ]  # If ufsdump had problems 
    then
        beepsysadmin "`uname -n` backup problem: ufsdump"
    fi
else
    add "\n************************************"
    add "\nAbort of ufsdump: no raw snap device"
    add "\n************************************"
fi

add "\n"

/usr/lib/fs/ufs/fssnap -i | \
  egrep "Mount|Raw|Backing store size" \
  >> ${sess_file} 2>&1

add ""

# Delete UFS snapshot
/usr/sbin/fssnap -d ${file_sys} >> ${sess_file} 2>&1

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

# and exit script.
exit 0