1833875 Members
1915 Online
110063 Solutions
New Discussion

tar question

 
SOLVED
Go to solution
Andrew Griffin
Advisor

tar question

I'm writing a script to transfer a database from one system to another, both are HP-UX servers. The server I'm moving them from stores the files in 6 directories - /r10, /r20, /r30, etc. And the new server will store them in 5 directories - /data1, /data2, etc. The files have to be rearranged in the process to evenly spread them out across the new mount points. This is an example of what I'm doing (so far) in the script, moving a list of specific files to their new directory on the new server:

tar cvf - /r10/file1.dbf /r60/file4.dbf /r20/file3.dbf /r40/file9.dbf | remsh host2 '(cd /data1; tar xvf -)'

The problem is when the files are extracted (at the "tar xvf -" part), they're being restored to their original absolute path locations. Since the new server doesn't have any of the /rXX directories, they're being created and filling up the / file system. Here's my question: Which tar option do I use, when extracting the files, to ignore the absolute path names and just restore to the current directory?
5 REPLIES 5
Helen French
Honored Contributor
Solution

Re: tar question

Hi Andrew,

While doing backup ( tar -cvf ) , specify the relative path instead of absolute path.

# cd /rxx
# tar -cvf /dev/rmt/0m .

This will restore the files to the current directory while doing tar -xvf

HTH,
Shiju
Life is a promise, fulfill it!
Sandip Ghosh
Honored Contributor

Re: tar question

You have to go to the directory and then you have to give the tar comand. That means you have to use 6 tar commands in the script and before each separate tar command you have to give the change dir command to that directory.

Sandip
Good Luck!!!
Helen French
Honored Contributor

Re: tar question

Hi,

Again, if you stick with absolute path, then read this thread:

http://forums.itrc.hp.com/cm/QuestionAnswer/0,,0x835a50011d20d6118ff40090279cd0f9,00.html

and Harry's suggestion here:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x38d6cf38d6bdd5118ff10090279cd0f9,00.html

HTH,
Shiju

Life is a promise, fulfill it!
Andrew Griffin
Advisor

Re: tar question

Thanks all, that's what I thought, just wanted to make sure. I'm going to modify the script as such:

cd / ;
tar cvf - r10/file2.dbf r60/file8.dbf r20/file3.dbf | remsh host2 '(cd /data1; tar xvf -)'

etc., etc..

Thanks for the help!
Jeff Schussele
Honored Contributor

Re: tar question

Hi Andrew,

Just a reminder that tar cannot handle files > 2 Gb - even if the FS is set to support largefiles.
Something to keep in mind if those DB files grow down the road.

Rgds,
Jeff

PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!