Operating System - HP-UX
1833782 Members
2839 Online
110063 Solutions
New Discussion

Re: Why tar Can Not Back Up All

 
SOLVED
Go to solution
Steven Chen_1
Super Advisor

Why tar Can Not Back Up All

Hi,

I have a script to get tar to backup 3 directories, but only the last directory files are backed up. I wonder why and would like to have some comment.

The codes are like:
--------------------------

#!/bin/sh
cd /disk7/aaa
tar cvf /dev/rmt/c2t0d0BEST /disk7/aaa
#
cd /disk8/bbb
tar cvf /dev/rmt/c2t0d0BEST /disk8/bbb
#
cd /disk3/ccc
tar cvf /dev/rmt/c2t0d0BEST /disk3/ccc
#
#eof
---------------------------------------

So only /disk3/ccc files being backed up. That measn only last line of codes is executed.
Is it strange?

Thanks,

Steven
Steve
11 REPLIES 11
Patrick Wallek
Honored Contributor
Solution

Re: Why tar Can Not Back Up All

You must use the no-rewind tape device in order for your backup to work properly. Replace the /dev/rmt/c2t0d0BEST with /dev/rmt/c2t0d0BESTn and your backups will work.

Without the no-rewind device file the tape is getting rewound after each tar session, thus each backup overwrites the previous and you are only left with the last backup.

Do the step above and it will work for you.
A. Clay Stephenson
Acclaimed Contributor

Re: Why tar Can Not Back Up All

Hi Steven,

This is is easy. Actually all 3 are being backed up but since you are using a rewind device the first two are overwritten each time.
If you will switch to /dev/rmt/c2t0d0BESTn, things will be better.

Regards, Clay
If it ain't broke, I can fix that.
Kofi ARTHIABAH
Honored Contributor

Re: Why tar Can Not Back Up All

Steven:

In addition to the above, you could do :

tar -cvf /dev/rmt/.... -C /disk7/aaa -C /disk8/bbb -C /disk9/ccc etc.

check:
man tar

good luck
nothing wrong with me that a few lines of code cannot fix!
Steven Chen_1
Super Advisor

Re: Why tar Can Not Back Up All

Thanks for all the help.

BTW, can someone explain what c2t0b0BESTb and nb means?

Steven
Steve
Patrick Wallek
Honored Contributor

Re: Why tar Can Not Back Up All

The normal device file c?t?d?BEST are AT&T best density
The c?t?d?BESTb are Berkely best density
You add the 'n' c?t?d?BESTn or c?t?d?BESTnb and that makes them no-rewind device files.

As to the difference between AT&T and Berkeley, I'm not sure.

A. Clay Stephenson
Acclaimed Contributor

Re: Why tar Can Not Back Up All

Hi Steven, Patrick:

You can man mt for a very explanation of the berkeley and AT&T tape behavior.

Clay
If it ain't broke, I can fix that.
Patrick Wallek
Honored Contributor

Re: Why tar Can Not Back Up All

Thanks for the point in the right direction for AT&T vs. Berkeley, Clay. That does explain it pretty well.
Bill Hassell
Honored Contributor

Re: Why tar Can Not Back Up All

One additional point: start using the lssf command instead of ls -l or ll for all device files. The names of device files are subject to change so you need a tool to actually decode what the major/minor numbers actually mean.


Bill Hassell, sysadmin
Steven Chen_1
Super Advisor

Re: Why tar Can Not Back Up All

Thanks for the help and I get what I want -- all are tar up.

However, I don't get it is it is still in absolute path that is not what I desire. Otherwise I simply use tar with all directories.

While I cd to proper directory, and have tar to backup, how come I still get absolute path with slash?

Anyway to get a relative path in this case?
Steve
Victor BERRIDGE
Honored Contributor

Re: Why tar Can Not Back Up All

Hi Steve,
In order to backup with tar directories with relative path, once in the directory use . in your tar:
cd /home; tar -cvf {tapedevice} .

It will archive from this directory as ./files...

All the best

Victor
Curt Thompson
Respected Contributor

Re: Why tar Can Not Back Up All

Hello Steven,

One more option.

Continue to use the same devicefile you have always used before. Instead, use tar with the
'-r' option. This will append a new file to the end of the archive without regard to its current position. This is most helpful if you rewind or eject the tape and then need to add more to it later.

For example:
tar -rvf /dev/rmt/c4d0t0BEST yourfile

Good Luck,
Curt