Re: automating tbtape on Informix V5
Posted in 1996
Dana Lloyd (danal@austin.ibm.com) wrote: : Actually, I'm kinda surprised that I didn't get flooded with simple : sample scripts. V5 has been around for a very long time. Maybe everyone : has migrated away from it and already recycled those brain cells, or : given them a good burial. I don't like the idea of having someone sit : around at night just to stuff tapes when I have the materials and : technology, minus tbtape of course, to do it. Oh yeah, just in case you DO have one of those nasty OS's that won't let you go over 2 or 4GB, here are a couple of programs/scripts I dug up. Unfortunately, I can't tell if they are exactly what you're looking for, or maybe they just need to be tailored to your environment, but anyway... June ---- June Tong Informix Software ---- ---- Senior Consultant (415) 926-6140 ---- ---- International Support junet@informix.com ---- ---- Location-du-jour: Menlo Park ---- - - Please do not send me requests/questions by mail. When I have the knowledge - and time permits, I try to answer questions on comp.databases.informix, but - travel schedule, time, and volume make responding to personal requests - difficult and often slow. Please call your local Informix Technical Support - organization for assistance with technical issues. ============================================================================= Tech Info Article #3804 Title: Shell scripts for doing archive through tbmonitor [NOTE: The following is known as a "shell archive" This denotes a special way to put ascii files together into a single file and separate them out later. To exract the files in this archive, edit this file so that the #!/bin/sh line is the first line of the file, then run `sh filename` from the Unix command line.] QUESTION: Why can you do an archive through tbmointor and on the command line, but cannot do one via a script. ANSWER: Here's a shell archive containing the code for the shell scripts used at one of our customer sites to drive tbmonitor for archive/restore. These scripts are highly tailored to the environment so you'll need to do some modifications, but it should give you some ideas. #!/bin/sh # This is a shell archive (shar 3.10) # made 10/02/1990 15:34 UTC by mjeske@hh900nr # Source directory /newres/mjeske/tools # # existing files WILL be overwritten # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 4447 -rwxrwxrwx dbarchive # 3792 -rw-r--r-- dbrestore # touch 2>&1 | fgrep '[-amc]' > /tmp/s3_touch$$ if [ -s /tmp/s3_touch$$ ] then TOUCH=can else TOUCH=cannot fi rm -f /tmp/s3_touch$$ # ============= dbarchive ============== sed 's/^X//' << 'SHAR_EOF' > dbarchive && X#!/bin/sh X# dbarchive: automatic level 0 archive X# original author: Carlos Godinez/INFORMIX X# @(#)dbarchive 1.3 /usr/informix/backup/sh/s.dbarchive X# @(#)dbarchive 1.3 /usr/informix/backup/s.dbarchive X# last update:8/25/90 @ 11:37:06 X X# XTBCONFIG=tbconfig;export TBCONFIG X X# Added to insure matching block sizes in "dbarchive" and "dbrestore". MAK XSIZE=`grep "^TAPEBLK" $INFORMIXDIR/etc/tbconfig|awk '{print $2}'` Xif [ "${SIZE}" != "972" ];then Xecho TAPE BLOCK SIZE IS INCORRECT.. PLEASE RESET THE TAPEBLK TO 972 Xexit Xfi X X## Check to see User ID = "informix" Xif [ "`ucb whoami`" != "informix" ] Xthen X echo "\\nUSAGE: $0: Must be executed as User ID = informix\\n" >&2 X exit 1 Xfi X X# test for one parameter and that it is 1, 2, or 3 Xcase "$1" in X 0) LVL=0;; X 1) LVL=1;; X 2) LVL=2 X echo tmp unavailable X exit 99;; X *) echo "\\nUSAGE: dbarchive [0|1|2]" X exit 2; Xesac X X# check that INFORMIXDIR is set X: ${INFORMIXDIR:?"INFORMIXDIR is not set"} X X# Set PATH just in case XPATH=$INFORMIX/bin:$PATH; export PATH X X# Check for TBCONFIG X: ${TBCONFIG:?"TBCONFIG is not set"} XTBCNFG=$INFORMIXDIR/etc/$TBCONFIG; export TBCNFG X X# Check that the system is in On-Line or Quiescent mode XMODE1=`tbstat - | grep "On-Line"` XMODE2=`tbstat - | grep "Quiescent"` X[ -z "$MODE1" -a -z "$MODE2" ] && { echo "\\nERROR: OnLine is not On-Line or Quiescent mode"; exit 3; } X X# Set dummy tape device from tbconfig XTPLINK=`sed -n '/^TAPEDEV/ s/TAPEDEV//p' $TBCNFG` X[ -z "$TPLINK" ] && { echo "\\nERROR: dummy backup device not set"; exit 4; } X X# Set environment variables XBUDIR=/usr/informix/backup # Backup directory XBASETIME=`date +%m%d%R` # Time stamp for the in/out files XTIMESTAMP=`date "+%D %T"` # Time stamp for the log file XFILEDEVS=${BUDIR}/level$LVL # Name of file containing backup devices X X# Mark the file with the number of the day_of_the_week X# This allows seven logs before over-writing XRUNLOG=${BUDIR}/logs/level${LVL}_`date +%w` X X# This file will contain the Start and End times X# of the last 100 archives at ${LVL} XLEVLOG=${BUDIR}/logs/level${LVL} # GTH X X# Check that the file containing device names is readable X[ ! -r "$FILEDEVS" ] && { echo "\\nERROR: cannot read ${FILEDEVS}"; exit 5; } X X# Set temporary filenames XIN=/tmp/in${BASETIME} # Feeds keystrokes to tbmonitor XOUT=/tmp/out${BASETIME} # Holds tbmonitor's output X X# Set messages expected from tbmonitor XBCKLVL="'Level $LVL archive is 100 percent completed.'" XNEXTTAPE="'Please mount next tape and press Return to continue...'" X X# Build input shell on the fly Xcat >$IN <<E-O-F X#!/bin/sh X# input shell X X# read from file and set backup devices XDEVICES="`cat $FILEDEVS`" X X# Set devices to \\$1, \\$2, \\$3, (positional parameters) Xset \\$DEVICES X X# Link tape device to first device XDEV=\\$1 Xrm -f $TPLINK 2>/dev/null # Remove any existing link Xln \\$DEV $TPLINK 2>/dev/null X X# Check for the link X[ "\\$?" -ne 0 ] && { echo "\\nERROR: link failed"; exit 6; } X X# Create the RUNLOG Xecho \\$DEV > $RUNLOG X X# answers to tbtape Xecho "ac" Xsleep 10 Xecho "\\r" Xsleep 10 Xecho "$LVL\\r" Xsleep 5 X X# Continue backup in second device if necessary X# Move the next argument into \\$1, after all, there are more than 9 devices Xshift X X# test for end of backup Xgrep -s $BCKLVL $OUT Xwhile [ "\\$?" -ne 0 ] Xdo X sleep 10 X X # Test for additional tapes/devices X grep -s $NEXTTAPE $OUT X if [ "\\$?" -eq 0 ]; then X # Empty the output file X >$OUT X X # Check for another device X if [ \\$# -gt 0 ] X then X # Set next backup device X eval DEV=\\$1 X else X echo "$0: Ran out of archive devices" >&2 X exit 7 X fi X@@NL