- 论坛徽章:
- 0
|
Following is a script for unattened archive to disk files, it supports multiple vol archive for those who has 2GB file size limitation. I wrote it long time ago, tested in AIX 4.3. Just for you to play in your testing env.
#!/bin/ksh
#
# Usage : autotape [0|1|2] | ontape -s > ontape.log
#
#
## Set Informix running env
INFORMIXDIR=/informix_app
INFORMIXSERVER=ifmxdba
ONCONFIG=onconfig.ifmxdba
INFORMIXSQLHOSTS=/dms/informixtest/sqlhosts
NOFUZZYCKPT=1
export INFORMIXDIR INFORMIXSERVER ONCONFIG INFORMIXSQLHOSTS NOFUZZYCKPT
PATH=$INFORMIXDIR/bin:. PATH
LOGDIR=`pwd`
BACKUPDIR=`pwd`
DATE=`date +%m%d%C%y`
SEQ=0
TAPEDEV=`sed -n '/^TAPEDEV/ s/TAPEDEV//p' $INFORMIXDIR/etc/$ONCONFIG \
| awk '{print $1}`
LOGFILE=$LOGDIR/ontape.log
## Check if loginin as informix
if [ "`whoami | cut -c1-8`" != "informix" ]
then
echo "\nUSAGE: $0 must be executed as informix" >&2
exit 1
fi
## Check if the system is in On-Line or Quiescent mode
MODE1=`onstat - | grep "On-Line"`
MODE2=`onstat - | grep "Quiescent"`
[ -z "$MODE1" -a -z "$MODE2" ] && { echo "\nERROR: OnLine is not On-Line or Quiescent mode"; exit 2; }
if [ $# -lt 1 ]
then
echo "Usage: $0 [0|1|2] | ontape -s > ontape.log"
exit 3
fi
## Get the archive level and it should be 0, 1, 2
LEVEL="0"
case "$1" in
0) LEVEL="0"
;;
1) LEVEL="1"
;;
2) LEVEL="2"
;;
esac
## Set up tape
cat /dev/null > $TAPEDEV
chmod 660 $TAPEDEV
sleep 2
## Answer to ontape of the archive level
echo $LEVEL
sleep 2
## Answer to ontape of mount tape and press Return
echo ``
sleep 2
##
while true
do
CHECK=`tail -1 $LOGFILE | awk '{print $2}' | sed '/^$/d'`
## check ontape.log file if ontape asked for mounting new tape
if [[ $CHECK = "mount" ]] then
SEQ=$((SEQ+1))
mv $TAPEDEV $BACKUPDIR/arc.$LEVEL.$DATE.$SEQ
cat /dev/null > $TAPEDEV
chmod 660 $TAPEDEV
echo "\nTape $SEQ compelted, saved as arc.$LEVEL.$DATE.$SEQ" >> $LOGFILE
sleep 6
echo ``
fi
## check if the archive finished
if [[ "$CHECK" = "over." ]] then
SEQ=$((SEQ+1))
mv $TAPEDEV $BACKUPDIR/arc.$LEVEL.$DATE.$SEQ
cat /dev/null > $TAPEDEV
chmod 660 $TAPEDEV
echo "\nTape $SEQ compelted, saved as arc.$LEVEL.$DATE.$SEQ" >> $LOGFILE
sleep 6
exit 0
fi
done |
|