[comp.unix.xenix] ADDING TO TAR TAPE ARCHIVES - scripts

root@netdev.Comsys.COM (Alex Huppenthal) (03/14/90)

SCO Xenix 2.3.2 GT, doesn't support adding to an existing tar tape.

These scripts do.

I've tested these tonight, for a few minutes. They appear to 
do the expected. 

If you are aware of a more elegant solution, I'd like to hear from 
you. In the mean time, if you've been battling the same problem,
these scripts allow you to make use of all the tape on a 150MB 
backup, not just the initial tape write.

Change the /etc/default/tape and tar entries, and execute these short
scripts, where appropriate, and you may end up as happy as I am.

Enjoy.

If you add to these, or find make additions, like range checks, error checks,
logfiles, etc, I'd love to receive the updates.

-Alex


Standard disclaimer:  We take no responsibility for these, of any kind.

Note: This shar archive will unpack into the current directory.


# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by root on Wed Mar 14 01:02:25 CST 1990
# Contents:  add all check ctape goto tape tar
 
echo x - add
sed 's/^@//' > "add" <<'@//E*O*F add//'
#     Archive Tape Fix for SCO Xenix 2.3.2GT
#
#         AHA1540A + Archive 2150s tape backup system
#         workaround to allow tar additions to tape archives.
#
#	  March 12, 1990	alex@comsys.com
#
#         This script adds files to the end of a tape.
#	  For the Archive 2150s tape unit, the parameters
#	  are 150000 1 kilobyte blocks, 20 is the blocking factor
#        
#         The non-rewinding device /dev/nrct0 is specified in the tar line.
#         If you'd like to rewind the tape after tar completes,
#         change the tar command in this script to point to /dev/rct0
#
#         Tar reports 'Seek= 00 K ' - what does it know, really?
#	  
#	  Disclaimer: Good luck. If it breaks, oh well, go back to
#         using 10MB of each $25 tape, as I did before.
#
#         If you find this useful, post something of value, or make a
#         donation to a charitable organization.
#
#
#
echo 'Add,  Version 0'
count=0
while true
  do
   tape rfm /dev/nrct0 2>/dev/null || break
   count=`expr $count + 1 `
   echo "past fileset $count "
  done
tar cvfbk /dev/nrct0 20 150000 $*
echo 'Files added to /dev/nrct0 '
echo 'Tape positioned for next write'

@//E*O*F add//
chmod u=rwx,g=rx,o=rx add
 
echo x - all
sed 's/^@//' > "all" <<'@//E*O*F all//'

#    all
#	   This script prints a verbose tar listing of     
#	   on the tape, first printing the Tape archive 
#          number.
#	  
#	   I use it for listing the contents of tar tapes 
#          to build a tar library index.  - alex@comsys.com 
#	   
#
#
echo "all: Tar tape listing - `date`"
count=1
tape rewind
while true
  do
   echo 
   echo "Tar dataset number $count"
   tar tvf /dev/nrct0 2>/dev/null || break 
   count=`expr $count + 1`
  done
echo "/dev/nrct0"
tape rfm /dev/nrct0 2>/dev/null
echo "tape at end of archives"
@//E*O*F all//
chmod u=rwx,g=rx,o=rx all
 
echo x - check
sed 's/^@//' > "check" <<'@//E*O*F check//'
# check
#      prints a verbose listing of the archive, and leaves 
#      the tape at the next archive position.
tar tvf /dev/nrct0
@//E*O*F check//
chmod u=rwx,g=rx,o=rx check
 
echo x - ctape
sed 's/^@//' > "ctape" <<'@//E*O*F ctape//'
#    ctape
#	   This script prints the number of tape data sets
#          on the entire tape backup, starting at the current
#	   position to the end.
#          
#          If you'd like a count of the entire tape, issue
#
#            tape rewind 
#
#          then run this script, or add it to this script.
#
#          alex@comsys.com
#
#
echo 'ctape: Counting file sets from current tape position'
count=0
while true
  do
   tape rfm /dev/nrct0 2> /dev/null || break
   count=`expr $count + 1`
   echo "Found $count"
  done
echo "/dev/nrct0"
echo "$count tar archives found"
echo "tape positioned for next write"
@//E*O*F ctape//
chmod u=rwx,g=rx,o=rx ctape
 
echo x - goto
sed 's/^@//' > "goto" <<'@//E*O*F goto//'
#	goto [arg]
#          Moves the tape from the beginning 
#          to the [arg] filenumber. 
#         
#          This, used with the 'all' command, allows you
#          to begin restoring date the tape from a selected 
#          archive location.
#
#          By issuing a 'goto 5' this script moves 4 tape file
#          marks into the tape archive. You may tar xvf /dev/nrct0 
#	   files/dirs.
#
#	   Note: A goto 1, is a NOP. You are already over position 1.
count=2
tape rewind
while [ $count -le $1 ]
  do
    tape rfm /dev/nrct0 2>/dev/null || 
       ( echo 'Tape position - at end of last archive'; exit )
    echo "Over position $count"
    count=` expr $count + 1`
  done
if [ $count -le 2 ]
 then  echo 'You are already at position 1'
fi
@//E*O*F goto//
chmod u=rwx,g=rx,o=rx goto
 
echo x - tape
sed 's/^@//' > "tape" <<'@//E*O*F tape//'
#
# this is the /etc/default/tape file
device = /dev/nrct0
@//E*O*F tape//
chmod u=rw,g=r,o=r tape
 
echo x - tar
sed 's/^@//' > "tar" <<'@//E*O*F tar//'
# this is the /etc/default/tar file used 
#
#	 device     		block   size	tape
archive0=/dev/rfd048ds9		18	360	n	
archive1=/dev/rfd148ds9		18	360	n
archive2=/dev/rfd096ds15	10	1200	n
archive3=/dev/rfd196ds15	10	1200	n
archive4=/dev/rfd096ds9		18	720	n
archive5=/dev/rfd196ds9		18	720	n
archive6=/dev/rfd0135ds18	18	1440	n
archive7=/dev/rfd1135ds18	18	1440	n
archive8=/dev/rct0		20	150000	y
archive9=/dev/rctmini		20	0	y
# The default device in the absence of a numeric or "-f device" argument
archive=/dev/nrct0		20	150000	n
@//E*O*F tar//
chmod u=rw,g=r,o=r tar
 
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
     37    203   1169 add
     24     88    541 all
      4     23    133 check
     25    101    620 ctape
     25    131    757 goto
      3     10     59 tape
     15     71    524 tar
    133    627   3803 total
!!!
wc  add all check ctape goto tape tar | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0
-- 
Alex            Internet:  root@comsys.COM
Huppenthal          UUCP:  {cs.utexas.edu!texbell}!netdev!alex 
Communication Systems Research  6045 Buffridge Tr, Dallas, TX 75252