Home Contact
Validate the HTML of this page

Voyager NetWorker Script

savevygr

Session File
#!/bin/sh

###############################################################
#
#   Shell Script: savevygr
#
#   1998, 1999, 2000, 2005, 2007
#   Michael Doran, doran@uta.edu
#   University of Texas at Arlington Library
#
#   see man pages for fssnap and fssnap_ufs
#
###############################################################

# Variables:
 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=/var/fssnap                  # Backing store directory
 bs_file=${bs_dir}${file_sys}-bsf    # Backing store file
 tmp_mnt_pnt=/m1-snap                # Temporary mount point

# Function to mail error messages
senderr ()
{
    /usr/bin/echo "$1" | mailx -c doran -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"

# shut Voyager down
servers stop

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

# Create backing store directory if needed
if [ ! -d ${bs_dir} ]
then
    mkdir -p ${bs_dir} >> ${sess_file} 2>&1
fi

# Create UFS snapshot
block_snap_dev=`/usr/sbin/fssnap -F ufs \
 -o unlink,backing-store=${bs_file} ${file_sys}`

add "\n${file_sys} backup via ${block_snap_dev} snapshot mounted on ${tmp_mnt_pnt}"
# 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

if [ ! -d ${tmp_mnt_pnt} ]
then
    mkdir ${tmp_mnt_pnt} >> ${sess_file} 2>&1
fi

# Mount snapshot on temporary mount point
/usr/sbin/mount -F ufs -o ro ${block_snap_dev} ${tmp_mnt_pnt} \
	>> ${sess_file} 2>&1

add "Running Legato NetWorker save command..."
# Do backup via NetWorker save command
/usr/sbin/save "$@"
exit_status=$?
add "NetWorker exit status: ${exit_status}"
if [ ${exit_status} -ne 0 ]  # If save had problems 
then
    beepsysadmin "`uname -n` backup problem"
fi


# Unmount snapshot from /backup mount point
/usr/sbin/umount ${block_snap_dev} >> ${sess_file} 2>&1

add "\n"

/usr/lib/fs/ufs/fssnap -i | \
  egrep "Mount|Block|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