Operating System - HP-UX
1833108 Members
2683 Online
110051 Solutions
New Discussion

How to read all files on "tar" tape

 
Mauro Gatti
Valued Contributor

How to read all files on "tar" tape

I write on tape with tar every day using /dev/rmt/0mn some files.
If I want to know a list of files on tape how can I do?
I must rewind tape ad do a "tar tvf" for each file written using 0mn special file... but if I don't know the number of writes on tape how I could automatize a script that lists all files on tape?

Thank You


Ubi maior, minor cessat!
8 REPLIES 8
Kurt Beyers.
Honored Contributor

Re: How to read all files on "tar" tape

tar -tvf /dev/rmt/0mn > /tmp/tar.log

will show you the contents of the files written on the tar tape and redirect it to the file /tmp/tar.log. Or just do a grep for the file you want.

Kurt
Bill Hassell
Honored Contributor

Re: How to read all files on "tar" tape

Are you appending multiple tar archives onto the same tape? This can be very dangerous since using the wrong comnmand to space over previous archives may accidently destroy some or all of the old backups. For that reason, trying to maximize the use of each tape may be very detrimental to the old data on the tape.

Otherwise, tar tvf /dev/rmt/0mn will display an index to all the files for a single tar archive. Repeat the command using the 0mn (no rewind) to see additional archives.

tar is an archaic utility and should be used only for casual data interchange. tar does not handle large files and is unable to recover from media errors.


Bill Hassell, sysadmin
Tim D Fulford
Honored Contributor

Re: How to read all files on "tar" tape

Hi

As the above has suggested tar tvf /dev/rmt/0mn. But I believe your question was also to find how many tape writes there were. use "mt" to do this

mt -fsf 1 -t /dev/rmt/0mn

This will forward the tape by 1 tar write, repeat 'till it cesses to work.

Regards

Tim
-
Mauro Gatti
Valued Contributor

Re: How to read all files on "tar" tape

My goal is to archive multiple file into same tape sequentially at different days and to write a "check script" that read all tape for extract all file written on.

Could You suggest me any idea to do this?
Ubi maior, minor cessat!
Mauro Gatti
Valued Contributor

Re: How to read all files on "tar" tape

I'm tring with this action:
starting from a blank tape:

#for i in 1 2 3 4 5 6 7 8 9
>do
>tar cvf /dev/rmt/0mnb prova$i.txt
>done
a prova1.txt 4 blocks
a prova2.txt 4 blocks
a prova3.txt 4 blocks
a prova4.txt 4 blocks
a prova5.txt 4 blocks
a prova6.txt 4 blocks
a prova7.txt 4 blocks
a prova8.txt 4 blocks
a prova9.txt 4 blocks

#mt -f /dev/rmt/0mnb status
Drive: HP C1537A
Format: DDS-3 format
Status: [81112500] EOF online compression immediate-report-mode
File: 9
Block: -1

#mt -f /dev/rmt/0mnb bsf 1
#tar tvf /dev/rmt/0mnb
Tar: blocksize = 0; broken pipe?

Why i get this error?



Ubi maior, minor cessat!
Bill Hassell
Honored Contributor

Re: How to read all files on "tar" tape

The bsf (backspace file) command moves past one tapemark (file separator). Since tar had read past the tapemark (and the status is EOT or at the end-of-tape marker, the tape was left positioned at the end of the previous file but just before the tape marker. Use a bsf 2 and it should see the tar archive.


Bill Hassell, sysadmin
Mauro Gatti
Valued Contributor

Re: How to read all files on "tar" tape

I must do "two time" tar to read correct file...

#mt -f /dev/rmt/0mnb bsf 1
#tar tvf /dev/rmt/0mnb
Tar: blocksize = 0; broken pipe?
#tar tvf /dev/rmt/0mnb
rw-r--r-- 0/3 1730 Jul 31 15:15 2003 prova9.txt


#mt -f /dev/rmt/0mnb bsf 2
#tar tvf /dev/rmt/0mnb
Tar: blocksize = 0; broken pipe?
#tar tvf /dev/rmt/0mnb
rw-r--r-- 0/3 1730 Jul 31 15:15 2003 prova8.txt
#tar tvf /dev/rmt/0mnb
Tar: blocksize = 0; broken pipe?
#tar tvf /dev/rmt/0mnb
rw-r--r-- 0/3 1730 Jul 31 15:15 2003 prova9.txt
Ubi maior, minor cessat!
Enrico P.
Honored Contributor

Re: How to read all files on "tar" tape

Hi,
from man mt:

Spacing operations (back or forward space file or record) leave the
tape positioned past the object being spaced to in the direction of
motion. That is, backspacing a file leaves the the tape positioned
before the file mark, forward spacing a file leaves the tape
positioned after the file mark. This is consistent with all classical
usage on tapes.

I think the problem is that when you move back the tape is positioned before the file marker (check this http://www.faqs.org/faqs/aix-faq/part2/section-1.html for file marker).
Try to rewind completely, move the tape forward and check if the error is eliminated.

Enrico.