Operating System - HP-UX
1829050 Members
2457 Online
109986 Solutions
New Discussion

The tar command questions

 
ajk_5
Frequent Advisor

The tar command questions

Hi all,

I would like to know how I can view a specific file in a backup tape quickly using tar?

Also, How can I know how many bytes I did backup all files in the tape?

Thanks very much!

Best Regards
ajk
8 REPLIES 8
Massimo Bianchi
Honored Contributor

Re: The tar command questions

Hello,
what do you mean by "quicly" ?
As far as i know, there is no fast way , you can only use a "tar -tvf FILENAME" to list the content of the tar.

Tar has no funzionality like index in fbackup.

If you plan it, you can create an index file each time you create a tape, using

tar -cvf ARCHIVE FILES | tee -a /INDEXDIR/ARCHIVE.index

but this can only be usefull for the future.

HTH,
Massimo
Michael Tully
Honored Contributor

Re: The tar command questions


$ tar tvf myarchive /directory/filename
This will give the permissions/owner/bytes/date etc

To get the total you would have to write a small awk script to get total of the column of bytes.
$ tar tvf mayarchive >/tmp/archive.out

Regards
Michael
"When I have trouble spelling, it's called fat finger syndrome"
Anyone for a Mutiny ?
Michael Tully
Honored Contributor

Re: The tar command questions

Here's a simple way to get the total number of bytes.

$ tar tvf myarchive >/tmp/wrk

$ cat /tmp/wrk | awk '{t1+=$3}
>END {printf("Total %d\n",t1)}'

Regards
Michael
"When I have trouble spelling, it's called fat finger syndrome"
Anyone for a Mutiny ?
Leif Halvarsson_2
Honored Contributor

Re: The tar command questions

Hi,
As you can see, tar is not very useful as a general backup program. Perhaps you should look at fbackup or better, Data Protector or some other high end product.
RAC_1
Honored Contributor

Re: The tar command questions

tar -tvf tar_archive > /tmp/list.txt

Check list.txt.

No fast way here.
There is no substitute to HARDWORK
Jean-Louis Phelix
Honored Contributor

Re: The tar command questions

hi,

Concerning the view of a specific file, managing an index could be ok.

But to check the amount of data in a tar file, dd could be even faster ...

For example :

> ll /tmp/a
-rw-rw-rw- 1 phelix CST 26767360 May 21 10:59 /tmp/a.tar
> dd if=/tmp/a.tar of=/dev/null bs=1024k
25+1 records in
25+1 records out

Which means that you have 26*1024k plus one incomplete record (less than 1024k) in the file.

Regards.

It works for me (© Bill McNAMARA ...)
V. V. Ravi Kumar_1
Respected Contributor

Re: The tar command questions

Hi,
if ur using /dev/rmt/0m tape device, to view a file the only way is
# tar tvf /dev/rmt/0m

To know howmany bytes, redirect the tvf output to a file.
# tar tvf /dev/rmt/0m >/tmp/tar.lst
Write a small script
x=0
for i in `cat /tmp/tar.lst|awk '{print $3}'`
do
x=`expr $x + $i`
done
echo $x
Never Say No
John Meissner
Esteemed Contributor

Re: The tar command questions

This proceedure will pull off a gzip'd tar file of the tape. you can then look at it in a normal tar -tvf

cd /var/tmp
dd ibs=10k if=/dev/rmt/0m of=archive.gz
All paths lead to destiny