Re: Archive to disk
Posted in 2005
Have a look at script below. Feel free to modify, if required. It works
ok with Linux and IDS 9.40.UC3.
NB: 1. This script calls another shell script to transfer file to
network drive. Either comment is out that line or include your
own.
2. Don't forget to change TAPEDEV in onconfig
-----------------------------------------------------------------------------
#!/bin/bash
#-------------------------------------------------------------------------#
# Title : backup2disk.sh
# Author: Hari Gupta
# Dated : 07-02-2005
# Notes : This script will perform Level 0 archive to disk file. This
# disk file then is going to be zipped to reduce the staorage
# and ease of transfer to DR and network file server.
#
# Detailed logs are being written at every stage to find out
any
# issue.
#
# Revision History:
# 19-05-2005 Added ontail-tail to avoide huge contents to email when
# there is an error to write on tape etc.
#
#
#------------------------------------------------------------------------#
set -x
### settings in onconfig: TAPEDEV /IFMXDATA/TAPEDEV/tapedev
IFMXDEVDIR=/IFMXDATA/TAPEDEV
BACKUPDIR=/IFMXDATA/ontape-bkups/level0
LOGDIR=/fs1/backup_t_drive/tmp
export INFORMIXDIR=/usr/informix
export INFORMIXSERVER=authlive_shm
export ONCONFIG=onconfig.authlive
export PATH=$PATH:/usr/informix/bin
DATE=`date +"%Y%m%d-%H%M%S"`
rm -f ${LOGDIR}/ontape.log
rm -f ${LOGDIR}/ontape-tail.log
touch ${LOGDIR}/ontape.log
touch ${LOGDIR}/ontape-tail.log
echo "Level 0 archive - Live Database on ${DATE}" >>
${LOGDIR}/ontape.log
echo "------------------------------------------" >>
${LOGDIR}/ontape.log
# cd to the backup directory
cd ${BACKUPDIR}
# create the tape-file
touch tape-${DATE}
chmod 660 tape-${DATE}
chown informix:informix tape-${DATE}
# cd to the informix device file dir
cd ${IFMXDEVDIR}
# remove old link to tapedev
rm tapedev
# create the link to the newly created tape-file
ln -s ${BACKUPDIR}/tape-${DATE} tapedev
# start the backup
echo '0\\n\\n' | ${INFORMIXDIR}/bin/ontape -s -L 0 >>
${LOGDIR}/ontape.log 2>&1
if [ $? -eq 0 ]; then
echo " " >> ${LOGDIR}/ontape.log
echo "Level 0 Archive completed SUCCESSFULLY... " >>
${LOGDIR}/ontape.log
echo " " >> ${LOGDIR}/ontape.log
echo " "
echo "Preparing to comopress the ARCHIVE disk file" >>
${LOGDIR}/ontape.log
echo " " >> ${LOGDIR}/ontape.log
# reduce the size by gzipping the file
/bin/gzip ${BACKUPDIR}/tape-${DATE}
if [ $? -eq 0 ]; then
echo "Archive Successfully compressed ..." >>
${LOGDIR}/ontape.log
echo " " >> ${LOGDIR}/ontape.log
echo "Compressed archive is being sent to network location
now." >> ${LOGDIR}/ontape.log
sh /home/informix/scripts/remote-level0.sh
if [ $? -eq 0 ]; then
mv /IFMXDATA/ontape-bkups/level0/tape*
/IFMXDATA/ontape-bkups/archive
echo "Successful - File Transfer to network ..." >>
${LOGDIR}/ontape.log
echo "Program over." >> ${LOGDIR}/ontape.log
tail -n 100 ${LOGDIR}/ontape.log >>
${LOGDIR}/ontape-tail.log
mail -s "SUCCESSFUL - Archive to Disk" admins -c sbt <
${LOGDIR}/ontape-tail.log
else
echo "FAILED - File Transfer to Network ..." >>
${LOGDIR}/ontape.log
mv /IFMXDATA/ontape-bkups/level0/tape*
/IFMXDATA/ontape-bkups/archive
tail -n 100 ${LOGDIR}/ontape.log >>
${LOGDIR}/ontape-tail.log
mail -s "FAILED - Transafer Archive File to Disk" admins
-c sbt < ${LOGDIR}/ontape-tail.log
fi
else
echo "Failed compression ..." >> ${LOGDIR}/ontape.log
echo " " >> ${LOGDIR}/ontape.log
mv /IFMXDATA/ontape-bkups/level0/tape*
/IFMXDATA/ontape-bkups/archive
echo "Archive file (uncompressed) has been moved to
/IFMXDATA/ontape-bkups/archive." >> ${LOGDIR}/ontape.log
tail -n 100 ${LOGDIR}/ontape.log >> ${LOGDIR}/ontape-tail.log
mail -s "Archive FAILED during Compression...." admins -c sbt
< ${LOGDIR}/ontape-tail.log
fi
else
echo "Email being sent about failure of archive to disk" >>
${LOGDIR}/ontape.log
echo "Prover Aborted."
tail -n 100 ${LOGDIR}/ontape.log >> ${LOGDIR}/ontape-tail.log
mail -s "FAILED - Archive to Disk" admins -c sbt <
${LOGDIR}/ontape-tail.log
fi
-----------------------------------------------------------------------------
Good luck.
Hari
Neil Truby wrote:
> Does anyone have a script to tbtape/ontape to disk, and cope with archives
> bigger than 2GBytes via the TAPESIZE parameter?
>
> If so, could you please post to andrew.watson@ardenta.com, who's too shy to
> ask himself.
>
> Thanks
>
> --
> Neil Truby t:01932 724027
> Director m:07798 811708
> Ardenta Limited e:neil.truby@ardenta.com