Problem is, I don’t recall running into this problem on any other *nix system.
As far as rewinding and eod’ing every time, it would take too long. And there
is not tape argument to position the tape at a specific tape block number. So I
can’t rewind just a bit and go to eod.
I’ve been doing some experimenting, and have come down to a design that should
work in most cases. I tar and output the tar’s printf’s to a file. If I get a
$? of 0, I cat the file to the screen, and zero out the error counter, thereby
listing the contents of the tar file on the tape, but if I get a $? of 1, I
increment an error counter and don’t cat the file to the screen. I loop around
that, ending on an error count of greater than 1, which I only get at the end of
the tape with consecutive “no input” results from tar. The only way this scheme
would fail, would be if I get more than one “no input” in between two good
files. So far I haven’t. When I do get two bad tars between two goods, its
always one empty tar, and one “no input”. Most of the time I get one bad tar
between two goods, and it is a “no input” tar. On the occasion that get an
empty tar between to goods, it should just cat an empty file.
Now I have a new problem. The tar command that works at the command line,
doesn’t work in the script.
tar tvf /dev/tp0 2>tarout
puts both the blocksize message, and the “no input” message, as well as the
listing of the files in the tar archive, into the file tarout, from the command
But when I execute the same command from the script, it either cuts off the
2>tarout, or if I put “” in front of the 2 and >, it puts the blocksize and
“noinput” to the screen and nothing to the tarout file. I’ve tried:
tar 1>tarout 2>>tarout, but that doesn’t work either. I can’t seem to get the
combination that works in the script.
Paul Russell wrote:
Careful with tapes - they sometimes spin past the point you would expect.
When you read or write an archive the tape is not guaranteed to stop exactly
at the end of the archive - there might be some dead space (0 to N blocks).
Some newer drives might do this differently - no guarantee.
The only way to guarantee that you are at the eod is to rewind then do an
If you tar (and it spins a bit past the end) followed by an eod, you might
actually be locking on to the eod of a partially overwritten previous
archive - and yes you’ll thus have several (zero to size of overwritten old
archive) blocks of junk between your true archive and the supposed eod.
Possibilities: When you archive record the last block used by the archive,
or the number of blocks used. Then use these values to direct an exact tape
You could even do a tape position back a few blocks (less than size of
archive) and then do an eod.
If you find a repetitive solution that works cleanly please email it to me.
I need to do this for an upcoming project.
When using a Tape keep the few buttons on a VCR in mind. Also treat it as if
each command is given to a new person with no knowledge of what previous
people have done with the tape - they’ll default to always running the tape
forward unless you tell them otherwise.
Remember that the Tape drive is a sequential device with little memory. It
really only knows the block number it is pointing at. It doesn’t know how
you’ve arranged your data on tape and will happily spin along looking for
then next search item (eod…). Note that an eod command will always spin
the tape further along (never backwards) unless you are exactly at an eod -
and even that I wouldn’t guarantee without some testing or reading. Only a
random access device (RAM, Disk drive, CD, …) can jump to the true eod
whether it be forward or back - tapes are very old unintelligent technology,
even when their medium - DAT - is new.
J. Scott Franko <> firstname.lastname@example.org> > wrote in message
news:> 3987255A.7B954F90@switch.com> …
Update: I did some test and didn’t use the tape eod comamnd and still got
the problem. It appears the problem is in the pax binary (which process
tar command). I wrote a simple 1 block file 3 times in a row. then tape
rewind. then tar tvf. There was an error tar file in between each of the
good files. is there any way to write multiple tar files on the tape
without getting error or empty tar files in between?
“J. Scott Franko” wrote:
I’m having some trouble using the tape and tar commands.
On a daily basis, a script essentially executes a
tar cvbf 20 /dev/tp0 $files
to archive a months worth of separate daily tar files on one tape, each
morning at 2am by cron job, where $JOB_ARC is an environment variable
that contains the path to an archive directory and $files is a script
variable that contains a list of files to backup.
If you use tar tvf /dev/tp0 to see what is on the tape, you will see the
first tar file, the first time you execute the tar tvf command after a
rewind. But the second time you execute the command (without
rewinding), you will either see an empty tar file (blocksize: 20
message, but no files) or an error tar file (blocksize:20 message, “no
input” message), or possible multiple error or empty files, before you
see a good one again. The difference in tape position between a valid
tar file, and an empty one is usually 2 tape blocks. The difference in
tape position between a valid tar file and an error tar file is usually
0 blocks, although I have seen a case where there was difference of 1
block. When the error tar file comes out, you can echo $? and see a
- When a valid tar file or an empty tar file is encountered, $? is 0.
This creates a problem trying to loop and list the contents of all tar
files on the tape, with a varying number of files on the tape, because
of the varying number of days in a month, and a varying gap of bad files
or empty files in between good files.
Currently we use something simple like this:
tar tvf /dev/tp0 # list the contents of the first tar file on the tape
while $? -eq 0
tar tvf /dev/tp0 >2 /dev/null # skip the empty tar file
tar tvf /dev/tp0 # list the next good tar
Problem is, this loop ends when you get a “no input” tar file because $?
returns a 1, and, if there is more than one bad tar file in between,
then it doesn’t work either.
Why are the extra tar files there? I only do one tar cvf command every
night at 2am by cron. Could the tape eod command be adding the extra
gaps? Is this a bug?
The tape forward command is similarly bothered by these empty or error
tar files in between good tar files although its behavior can be
different from doing consecutive tar tvf commands. The tape backup
command doesn’t appear to work at all.