1847394 Members
2821 Online
110264 Solutions
New Discussion

Re: TAR Help.....

 
Rajkumar_3
Regular Advisor

TAR Help.....

Hai all,

I have 3 directories /home/classes ,home/lib, /home/config..

I need to take a backup of these three directories using "TAR".But while extracting i will declare an environment variable some thing like "TEST_HOME=/../.. . In this i will specify the path to extract the 3 directories...

How can we take perticular those 3 directories and how can we extract those directories in different paths...??

Any help please...

Raj
Oracle DBA
10 REPLIES 10
Deepak Extross
Honored Contributor

Re: TAR Help.....

You can't tell tar to use an arbitrarily defined environment variable.
Try this:
cd /home; tar cv classes lib config (... or just *)
Then , when you want to extract, you can do this:
cd $TEST_HOME; tar xv
This will extact all the directories tarred into $TEST_HOME.
If you want a separate path for each directory, use a temp directory like so:
mkdir -p /tmp/extracts; cd /tmp/extracts; tar xv ; mv ; mv ; ...

HTH
Deepak Extross
Honored Contributor

Re: TAR Help.....

Uh-oh.. Apologies to anyone who wanted to post a "I know the answer, but I wont post it till you improve your points allocation record"
:-)
Steven Sim Kok Leong
Honored Contributor

Re: TAR Help.....

Hi,

Use tar's -T (or --files-from F)option to get names to extract or create from file F

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Rajkumar_3
Regular Advisor

Re: TAR Help.....

Hai all,

Appolozise for every one..Please correct me where i havent assign points...

Regards
Raj

Oracle DBA
Deepak Extross
Honored Contributor

Re: TAR Help.....

Hi Rajkumar,

See Dan's post of Nov 13 in this thread
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x316efd3f91d3d5118ff40090279cd0f9,00.html

Regards,
Deepak.
Michael Tully
Honored Contributor

Re: TAR Help.....

Hi,

I believe these are most likely
the threads you are looking for.

http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0xfaebc6af36b7d5118ff10090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0xdcc8cf38d6bdd5118ff10090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0xd26cfd3f91d3d5118ff40090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x7bcecf38d6bdd5118ff10090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x8dfec6af36b7d5118ff10090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0xf0b6cf38d6bdd5118ff10090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0xf5b6cf38d6bdd5118ff10090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x93cfcf38d6bdd5118ff10090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x6a32630fe5c4d5118ff10090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x4e670b0717d1d5118ff40090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x1bcacf38d6bdd5118ff10090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x0db74e49c5cdd5118ff40090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0xc1cd4e49c5cdd5118ff40090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x66033d853cd9d5118ff40090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x5ce1f715edc6d5118ff10090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x06d1d08cc06fd511abcd0090277a778c,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x48750b0717d1d5118ff40090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x06d1d08cc06fd511abcd0090277a778c,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/ 1,,0x2c268ffa98a2d5118ff10090279cd0f9,00.html

Anyone for a Mutiny ?
Rajkumar_3
Regular Advisor

Re: TAR Help.....

Hai All

Once again Appolozise....

Regards
Raj
Oracle DBA
Darrell Allen
Honored Contributor

Re: TAR Help.....

Hi Raj,

If you create the tar using absolute pathnames for the files you backup, you will not be able to restore them to an alternate location. You will need to use relative pathnames for your backup.

HPUX 11.0's tar does not have either T or F option.

Deepak has the answer for you:
cd /home
tar cvf tarfilename classes lib config
cd $TEST_HOME
tar xvf tarfilename

Very important: be sure cd $TEST_HOME is successful before un-tarring. If not (for exampe the directory doesn't exist), you will be extracting into whatever directory you were in before trying to cd. After the cd command, check that $? = 0.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Steven Sim Kok Leong
Honored Contributor

Re: TAR Help.....

Hi,

I forgotten to mention that for the -T option, you will need to install GNU tar to have this option.

As already pointed out, the default tar that comes with HP-UX does not have it.

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com

Re: TAR Help.....

Hi

If you backup using ./home/classes ,./home/lib, ./home/config
you will be able to restore anywhere you want.