Auto Log Archiver
Posted in 1991
Topics: Server Administration, Logging & Checkpoints
Hi there, I mentioned the fact sometime ago that I had a *simple* shell script which allowed the Online logical logs to be backed up continuously with out the need for a dedicated terminal. Enough people have mailed me requesting info on it for me to think that it is worth posting. So here it is but be warned you can't expect anything as simple as this to be foolproof and if you rely to heavily on it your asking for trouble. ??? Note that :- 1) If you fill up your tape things will get very hairy !!! ( I suppose that it would be a good idea to have dameon running monitoring the number of the current logical log, when this reaches $last_log then the relevant users could be warned.) 2) The file $INFORMIXDIR/bin/CR cotains nothing more than a carriage return. 3) I could not get this to work with the ksh any ideas why ? 4) Send a quit or interrupt to stop the script. -cut here--cut here--cut here--cut here--cut here--cut here--cut here- #!/bin/sh ##################################################################### # # Program : save_logs.sh Author : Brian Gray # # Shell script to initiate the background task tbtape to continuously # back up the database logs of the online system. # # Amended by K Woghiren Mon Jul 8 11:38:20 BST 1991 # The commands have been seperated out into another file (save_logs) # which is then no-huped. # If you want to know why looking in the manual under nohup # # Amended by K Woghiren Tue Aug 13 10:40:22 BST 1991 # # admin is mailed with the number of the first log to be backed up and # and the last log that will fit on the tape. SHELL=/bin/sh export SHELL # Won't work with the ksh LOGS_PER_TAPE=25 if test $LOGNAME != "informix" # Not really needed then # since tbtape does echo " Only Informix can run this process " sleep 3 exit fi tput clear echo echo echo echo echo "Please insert tape and press Return to continue (q to abort) \\c" read dummy if test "$dummy" = "q" then exit 1 else # this Should find the first log that will be written to tape firstlog=`tbstat -l|grep "U\\-\\-" |sort -n +28 |line|cut -c28-30` lastlog=`expr $firstlog + $LOGS_PER_TAPE` echo " Commencing backup of logical logs at `date '+%a %d %h %T'` First log written will be No. $firstlog Last log that will fit is No. $lastlog " | tee /dev/tty | mail informix admin nohup save_logs & fi -cut here--cut here--cut here--cut here--cut here--cut here--cut here- #!/bin/sh ###################################################################### # # Written by K Woghiren # Program name: save_logs # FNAME=$INFORMIXDIR/tmp/$$.tbtape export FNAME trap ' cat $FNAME| mail admin && rm $FNAME ' 0 1 2 3 4 5 6 7 8 cat $INFORMIXDIR/bin/CR | tbtape -c >$FNAME -cut here--cut here--cut here--cut here--cut here--cut here--cut here- Regards Ken +-------------------------------------------------------------------+ | Ken Woghiren (DBA - Charles Taylor & Co Ltd) | | | | Email: kenw@cix.compulink.co.uk | | Snail: World Trade Centre, London E1 9UN ,ENGLAND | | Voice: + 44 71 522 7466 | +-------------------------------------------------------------------+