Re: tbtape -c in background
Posted in 1997
Topics: Backup & Restore, Server Administration, Logging & Checkpoints, Networking & sqlhosts Configuration
Joseph Allen wrote:
>
> This is a script I use to start the ontape -c process in the background
> whenever the instance's are restarted or after I have perform an Archive of
> the online instance.
> I keep a week of logical logs on disk. Which are dated and have a unique name
> I also backup these logs to tape before an Archive each night. The only
> problem one might have is If .. your logical logs grow in the course of a
> day greater than the space you have in the file system on which they are
> stored.
> I have been using this for about 6 month in a production and development env.
> and have had to restore several times from a level 1 archive with no problem
>
> # "@(#)startlog.sh - run informix ontape -c"
> EXITOK=0;SIGHUP=1;SIGINT=2;SIGTERM=1;SIGQUT=3
> TrapSigs="$EXITOK $EIGHUP $SIGINT $SIGTERM $SIGQUT"
> trap 'rm -f tmp$$ > /dev/null 2>&1; exit 0 ' $TrapSigs
> mail_list="informix jallen"
> PWD="/hp/informix/admin/logs"
>
> PROGDIR="/hp/informix/admin"
> engine_file="$PROGDIR/scripts/online.engines"
> engines=`grep -v "^#" $engine_file | cut -d ":" -f1`
> DATE=`date`
> dayofweek=`date +%u`
> BUDIR=/hp/informix/admin/backup
> error_file=${BUDIR}/arch_error
> ARCHIST=${BUDIR}/arch_history
>
> # stop any ontape -c process which is running
>
> pid=`ps -ef | grep "ontape -c" | grep -v "grep" | cut -c9-14`
> if [ "$pid" != "" ]
> then
> ps -ef | grep "ontape -c" | grep -v "grep" | cut -c9-14 | kill -15
$pid
> fi
>
> arch_logs()
> {
>
> dayofweek=`date +%u`
> olddate=`expr $dayofweek - 1`
> if [ "$olddate" = 0 ]
> then
> olddate=7
> fi
>
> # compress yesterdays logs
>
> OLDLOG=${BUDIR}/logs/L$instance$olddate
> compress $OLDLOG
>
> # null out logs that are one week old
>
> dayofweek=`date +%u`
> LEVLOG="/hp/informix/admin/backup/logs/L$instance$dayofweek"
> if test -w $LEVLOG.Z
> then
> cp -f /dev/null $LEVLOG
> chmod 666 $LEVLOG
> rm -f $LEVLOG.Z
> fi
>
> LEVLOG=${BUDIR}/logs/L$instance$dayofweek
>
> #Set LTAPEDEV in onconfig to a unique name the this day.
> cat $INFORMIXDIR/etc/$ONCONFIG | awk '
> {
> if ($1 == "LTAPEDEV")
> $2=backarc
> printf("%s\\n",$0)
> }' backarc=$LEVLOG > $INFORMIXDIR/etc/tblogtmp.int
> cp -f $INFORMIXDIR/etc/$ONCONFIG
$INFORMIXDIR/etc/$ONCONFIG"bk"
> mv -f $INFORMIXDIR/etc/tblogtmp.int
$INFORMIXDIR/etc/$ONCONFIG
> echo "Restarting log archiver..." >> $ARCHIST
> echo $LEVLOG >> $ARCHIST
> nohup $INFORMIXDIR/bin/ontape -c < $PWD/ontape_cr 1> /dev/null
2>&1 &
> echo "restarted"
> }
> # get the list of instances on my platform
> list=$engines
> # for each instance start ontape -c
> for instance in $list
> do
> ONCONFIG=`grep -v "^#" $engine_file | grep $instance | cut -d ":"-f2`
> DBSERVERNAME="$instance"
> INFORMIXSERVER="$instance" > export ONCONFIG
> export DBSERVERNAME
> export INFORMIXSERVER
> echo "Begin Logical log backup at `date` for $instance" >> $ARCHIST
>
> case $instance in
> devl_hp1)
> arch_logs
> ;;
> onlprod)
> arch_logs
> ;;
> esac
> # if any errors mail informix and dba
> if [ -s $error_file ]; then
> mail $mail_list < $error_file
> cp /dev/null $error_file
> fi
I'm sure this script works for you, but don't ever post it to
comp.unix.shell. They'll tear you limb from limb! :-)
--
Mark.
+------------------------------------------------------------------+
|Mark D. Stock - The West Solutions Group http://www.west.co.za |
| The Informix FAQ is at http://www.iiug.org |
|mailto:marks@west.co.za +-----------------------------------------+
|Tel: +27 11 803 2151 |If it doesn't work, force it! |
|Fax: +27 11 803 2189 |If it breaks, it needed replacing anyway!|
|Cell: +27 83 250 2325 |Well, that's how I code anyway! |
+------------------------+-----------------------------------------+