jbackup script


The following script may be useful for sites wishing to execute a daily backup procedure.

#!/bin/ksh

# The following 3 lines setup the environment for the backup
# to run via Cron.
#
export JBCRELEASEDIR=/usr/jbc
export LD_LIBRARY_PATH=$JBCRELEASEDIR/lib:/usr/ccs/lib:/usr/lib
export PATH=$PATH:/usr/jbc/bin

# CD to a directory that has disk space to hold tempory files
# used during jbackup.
#
cd /tmp

# Echo the start of backup information.
#
echo Backup Started `date`
echo

# Perform the backup creating a Stat file, The stat file needs to be
# somewhere outside the backup path other wise jbackup will try to backup
# the same file that it is writing to. The file also needs to be pre-created
# or it will fail. This will also need to store the output from the
# backup in a convenient area of the disk.
# Modify the device name to match the one on your system. It needs to be
# a device with rewind.
# Also the -m needs to be changed to the correct media size for your tape
# device.
#
find /data -print | sort | jbackup -m10000 -S/tmp/stats f /dev/rmt/1c -v 2> /tmp/Aviion_backup_log

#Display finish of backup messages
#
echo Backup Finished `date`
echo

# Verify that the backup was completed successfully. If backup failed
# then mail root with the error and also print a backup failed error
# message on the default printer. (add -d {printer name} to the lp
# statement if different printer is required.)
#
cat /tmp/Aviion_backup_log | egrep 'ERROR!|failed' > /tmp/error.check
if (test -s "/tmp/error.check") then
  echo Error in Aviion_backup_log >/tmp/mail.error
  cat /tmp/error.check >>/tmp/mail.error
  mail root < /tmp/mail.error
  banner 8500_backup failed `date` | lp
else

# If backup was successful then wait for 5 minutes to make sure that
# the tape has fully rewound. Then display start of verify message.
# The verify will check that the data on the tape is valid (i.e. no
# bad tape blocks etc.)
#
  sleep 300
  echo Verify Started `date`
  echo

# Start the restore (Remember to change the tape device to the relevent
# one for your machine) and store any output from the restore in a
# convenient area of the disk.
#
  jrestore -f/dev/rmt/1c -P 2> /tmp/Aviion_verify_log

# Display the verify finished message
#
  echo Verify Finished `date`

# Check the verify output for any errors. If any errors are found
# then mail root with the error and also print a verify failed
# error message on the default printer. (add d {printer name} to
# the lp statement of different printer is required.)
#
  cat /tmp/Aviion_verify_log | egrep 'ERROR!|failed' > /tmp/error.check
  if (test -s "/tmp/error.check") then
    echo Error in verification of Aviion_verify_log >/tmp/mail.error
    cat /tmp/error.check >>/tmp/mail.error
    mail root < /tmp/mail.error
    banner Aviion_verify of_backup failed `date` | lp
  fi
fi

# Backup finished
cd \


Files