Re: tbtape -c in background
Posted in 1997
Topics: Backup & Restore, Server Administration, Logging & Checkpoints, Networking & sqlhosts Configuration
At 01:46 PM 4/15/97 +0000, Mark D. Stock wrote:
>Dwight Rudolph Jr wrote:
>>
>> In article <334DEF28.20DC@west.co.za>, marks@west.co.za says...
>> >
>> >Greg Salmon wrote:
>> >>
>> >> Mark D. Stock wrote:
>> >> >
>> >> > Neil Truby wrote:
>> >> > >
>> >> > > I've been asked to set up a background script to automatically run a
>> >> > > continuous logical log backup when my UNIX server starts.
>> >> >
>> >> > This can be done, but is SO dangerous that I'm not even going to
>> >> > say how. I would only implement this idea if I could ensure an
>> >> > operator was present 24 hours a day to pull out the tape when the
>> >> > system crashes. Then of course they might as well do a manual one
>> >> > if they are sitting there anyway. :-)
>
>> Actually the whole log backup process sort of irritates me. We do a full
>> level 0 backup every night and we're willing to reload that backup
(losing a
>> day's work) if there's a disk crash. So the logical logs aren't worth all
>> that much to us.
>>
>> I realize there are lots of places that must recover every committed
>> transaction, but I'm sure there are lots, like us, that don't. An
option to
>> NOT do logical logs (like Rdb/VMS has) would be really welcome.
>
>There are two:
>
>1) Switch off logging at the database level. This assumes you
> are running an inteligent application that can detect and deal
> with this change.
>
>2) Set your logical log backup device to /dev/null. This is picked
> up as a special device and logs are freed automatically.
>
>Help that helps,
>--
> Mark.
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
O O O O O O . . . ______________________________ __======______T___
O ____ ||Joseph Allen | |H (602)582-1064 |
.] [__n_n_|DD[ ===___ |Email jsa14@worldnet.att.net| |W (602)631-7592 |
>(_________|__|__[_____]_|Fax (602) 582-1064 _|_ |Sr.DBA CSK Auto_|_
_/oo OOOOO oo' oo oo 'o^o^o o^o^o' 'o^o o^o'
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--+-+