From: sherwood@space.ualberta.ca (Sherwood Botsford)
Subject: Re: i need help with tar and tapes drives.
Organization: University Of Alberta, Edmonton Canada
Date: Tue, 10 Nov 1992 18:18:07 GMT

Joseph Alotta writes
> i am trying to tar backup files to tape. 
>  
> i can:
> 
> tar cvf /dev/rst0 /data/*
> tar tvf /dev/rst0
> tar xvf /devrst0  filenames.
> 
> without much problem.
> 
> but since my tape is not filled up, i'd like to append new files to
> the end of it.
> 
>  
> i tried "tar rvf /dev/rst0"  but it didn't work.  seems the r option
> is unsupported on my machine.  
> 
> i ftp'd gnutar and tried "gnutar -Avf /dev/rst0"  but that didn't  
work.
> i got cannot backspace errors.
>  
> people say i should use "mt -f /dev/nrst0 -fsf 99" to get to the end  
of  
> thetape and then "tar cvf /dev/nrst0 *", but i don't like having to  
> remember what segments i've used on the tape and what is in each  
segment.
> 
> can anyone help me to get gnutar to append?
>  
> btw, i am using a archive dat tape and a nextstation 3.0. and perl as  
a
> wrapper for all these commands.
> 
>  
> thanks in advance,

Appending in my limited experience only works with 9 track tapes.

You have a significant problem with Nexts in that they have a slightly  
flaky interface between the tape driver and the SCSI bus.  This results  
in periodic bus device reset being sent to every device.  The disk  
doesn't care.  It resets, and waits for a new command.  The tape drive  
on reset rewinds the tape.  The frequency of this occurence depends on  
network load, and disk activity, but running backups at night, I was  
getting them about once for every 4 hours of tape operation.   
Increasing nbuf has since made the problem go away, or at least become  
much less frequent.

When this happens, the program writing to the tape aborts, but if  
embedded in a script it will carry on.

However, that this can happen at all is bad news for anyone putting  
multiple archives on a tape, as a dumb script will happily clobber the  
beginning of your tape.   If you are going to do this, and if your  
files are important, you have to do it right.  This means you must  
check the status of the drive before each write, and on finding an  
error either abort the script, or reposition the tape and start again.

What does this have to do with Perl?
[Begin shameless plug...]

Well, for Nexts I wrote a set of scripts called TarChive that handle  
this problem from the command line.  It gives you a bit more than you  
want, and it doesn't try to append.  It does however keep track how  
many archives are on a tape and keeps track of what is in each archive.   
It also has a mechanism for labeling tapes, and prevents overwriting  
(by the scripts anyway) by someone other than the user's tape. (Even  
root can't write on your tape:  You might have left it in the drive and  
forgotten that cron was going to run at 2 a.m.)

TarChive is not elegant perl.  (Not very perlescent...)  I have used  
perl mostly for structure, with hoards of @message=`commandline parm`.
The backup part is based on gnutar.  The SCSI status is based on  
parsing the output of mt. (This makes it very unportable.  Nobody  
writes mt the same way.)  Tape labels are implemented by putting a very  
short tar file at the beginning of the tape.  Tape ownership is tracked  
by creating a file in /usr/local/tapelabels.  Every archive is written,  
then read and compared to the original.  The output of the compare pass  
is send to a ~/backups/TapeLabel-datestring-dirname so that later you  
don't have to read the tape to find something.  (It has a header that  
tells you that this archive is file number XX on Tape TapeLabel

TarChive is rugged however.  If the drive faults, it keeps track of  
what archive it was at, repositions the tape to the beginning of that  
archive, and restarts the operation.  I've had busy days when the drive  
faulted while in the process of repositioning the tape after a fault.   
It recovered from that.

Scripts for running a full user back, or for users to backup individual  
directories, for labeling and for erasing tapes are included in the  
package.

TarChive is on Sonata.cc.purdue.edu