Re: Informix Backups
Posted in 1998
(Try something like the following. I wrote it when I first started working
with informix. Its the first draft that never went anywhere but gets used
ofter. )
# The purpose of this script to to automate the backup of the database
# and to help ensure its integrity. The DB status is tested initially
# so that the DB can be restored to its pre backup status.
# Future mods will echo outputs to file and CRON the job. For now this will
# do
# Function to test the status of the database prior to backup.
Status_func () {
if [ `onstat -g ntm | grep INFORMIX | awk '{print $5}'` = "On-Line" ]; then
DBSTATUS="1"
elif [ `onstat -g ntm | grep INFORMIX | awk '{print $5}'` = "Quiescent" ];
then
DBSTATUS="0"
elif [ `onstat -g ntm | grep INFORMIX | awk '{print $5}'` = "for" ]; then
DBSTATUS="2"
#echo "You must bring the DB online to back it up"
#exit
fi
}
# Function to do an ontape backup "-s" at Level Zero "-L0" of the
# database myby at mysystem"mydb@mysystem"
Backup_func () {
ontape -s -L0 mydb@mysystem2>&1
}# When the DB is in Quiescent mode backup the DB and test to ensure that the
# db is still in quiescent mode when complete. Output errors to the screen.
Status_func
if [ $DBSTATUS = "0" ]; then
Backup_func
Status_func
if [ $DBSTATUS = "0" ]; then
echo "Backup complete. Database remains in queisent mode"
else
echo "The database FAILED to remain in quesent mode!!!"
fi
fi
# When the DB is On-Line shut it down to quiescent mode, test to make sure
it
# made it to quiescent mode, back it up, return the db to an on-line state
# and test to ensure that it made it. Otherwise output errors to screen.
if [ $DBSTATUS = "1" ]; then
# Move the DB to quiescent mode
onmode -sy
sleep 10
Status_func
if [ $DBSTATUS != "0" ]; then echo " The database FAILED to transistion from On-Line to Queiescent
mode"
echo " which is required for backup. Exiting prior to backup!!!!!"
exit
else
Backup_func
fi
# Return DB to original state
onmode -m
Status_func
if [ $DBSTATUS != "1" ]; then echo " The database FAILED to return to On-line mode. "
echo " check the state of the db with onmonitor"
else
echo " The backup completed and the database was returned "
echo " to On-line mode correctly"
fi
fi
if [ $DBSTATUS = "2" ]; then
oninit
sleep 10
onmode -sy
sleep 10
Status_func
if [ $DBSTATUS != "0" ]; then echo " The database FAILED to transistion from Off line to Queiescent
mode"
echo " which is required for backup. Exiting prior to backup!!!!!"
exit
else
Backup_func
fi
onmode -ky
Status_func
if [ $DBSTATUS != "2" ]; then echo " The database FAILED to return to Off line mode. "
echo " check the state of the db with onmonitor"
else
echo " The backup completed and the database was returned "
echo " to Off line mode correctly"
fi
fi
"in4mxbkup.sh" 88 lines, 2838 characters
d.berry@ukonline.co.uk wrote in message
<6jbp96$iv9$1@morse.news.easynet.net>...
>Im new to this Informix lark, Im predominantly a Sybase DBA (Sorry!) What
sort of backup solution to most people use for Informix e.g. scripts running
ontape (any examples please!?) or do people us OnArchive or OnBar (I can't
get this working with the Legato Storage Manager). For Information we're on
Solaris 2.5.1 with Informix 9.13 (UDO).
>
>Thanks
>
>Dan