TAR on the UNIX system

Tar on the unix system is used to archive files. It is not quite as convenient to use as backup on the VAX. Below is a few points you may want to consider.
Don't use absolute paths when you tar a file. Tar will insist on putting the file back using the absolute name. If the device, on which the file was, is no longer on the system you have a problem. (there are ways around it, talk to your unix manager if you get caught in this trap)
It is somewhat difficult to recover a subset of files on a tar tape. Imagine that you have a data analysis directory with lots of subdirectories which each have lots of datafiles and subdirectories in them. The structure may look like:
     /disk/ana/data1
     /disk/ana/data2
     /disk/ana/data3
     /disk/ana/data4
     .
     .
Suppose you do a tar from the ana directory as:
   cd /disk/ana
   tar -cvf /dev/rmt/1mbn .
and then later on want to recover only the data2 directory. You would read in the man page that the way to do that should be something like:
   tar -xvf /dev/rmt/1mbn `tar -tf /dev/rmt/1mbn | grep 'data2/'`
However, it there are many files and subdirectories with files in the data2 directory, this procedure will not work as the list of files gets too long to be handled, i.e., you are in trouble!

The way to do the backup is to keep the individual directories as separate files on the tar tape - by doing the tar as:

   cd /disk/ana
   tar -cvf /dev/rmt/1mbn data1
   tar -cvf /dev/rmt/1mbn data2
   tar -cvf /dev/rmt/1mbn data3
   tar -cvf /dev/rmt/1mbn data4
     .
     .    
That way you can use the mt function to skip to the directory of interest as:
   mt -f /dev/rmt/1mbn rew
   mt -f /dev/rmt/1mbn fsf 1
(that would put you at the start of the second file on the tape). To do the recovery of the files:
   cd /disk/ana
   tar -xvf /dev/rmt/1mbn 

Suppose that you did a tar with the -v option on and redirected the output to the file "950518.tape_tar". In order to extract the files under the diretory "tl/src" on the tape, you can generate an extraction script file as:
echo "tar -xvf /dev/rmt/1mbn \" >! tarext
grep tl/src 950518.tape_tar | awk '{print $2 " \\"}' >> tarext
chmod +x tarext  

torben@anl.gov