Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tar 2

Status
Not open for further replies.

jomons

Technical User
Dec 16, 2002
16
IN
Hi All,


I have a tar back up of two file systems & /etc directory.
How can resore a single file from that.When I give the following command

tar -xvf /dev/rmt/0 /etc/oratab.

oratab file in /etc directory is replaced.As far as know it should in the current directory.

If no, whats the command for it ?

Regards

Joe.


 

You have to go to the directory relative to where you archived it, first.

Cheers Henrik Morsing
Certified AIX 4.3 Systems Administration
& p690 Technical Support
 
Hi,

Unfortunately, you can restore it in your current directory only if archive has been build with relative path (and not with "tar cvf /dev/rmt/0 /etc") ...
 
in this case I always do the following trick:
I use the `mc' (NortonCommander clone), maybe you need a Linux box if mc doesn work on your OS.

Copy the tar file from the type somewhere on the disk.
With mc can view the content of the .tar file and browse the content.
Then you can make a copy of the file that you want, wherever you want.

PM __
___
 
I have seen another method of restoring such files elsewhere - unfortunately I can't search for it as the search facility isn't working at the moment. Perhaps someone recalls it, or has a copy?
 
Found this tip from chroot man page (on Solaris):

cd your_dir
cp /usr/sbin/static/tar .
dd if=/dev/rmt/0 | chroot your_dir tar xvf - /etc/init.d/ANNOUNCE
 
Sorry, better "dd if=/dev/rmt/0 | chroot your_dir tar xvf - /etc/oratab" in fact (/etc/init.d/ANNOUNCE was my stupid test ...)
 
Hi

Thanks for your replies.I am facing this problem only with /etc directory.The other files which I took the backup can be restored with respect to the current directory.But for /etc it is not working.The command I given for backup is the following

tar -cvf /dev/rmt/0 -C /etc /ksfc1 /ksfc2
OS = Solaris 8

Can any one tell me why is it so ?


regards

Joe
 
If I'm not mistaken, the -C option tells tar where to extract the files... Though I suppose this is different on Solaris. //Daniel
 
From man page, I'd say you should add a "." and write something like "tar -cvf -C /etc ."
 
Hi.

My backup is fine.My problem is when I store the files the /etc files its going and replcing the orginal files in /etc direcotry, which I do not want to happen.I want to extract the file to the current directoty and refer those.

whats command for that ?

I used
tar -xvf /dev/rmt/0 /etc/oratab

Please help me..!!!


Regards

Joe



 
nwardez' chroot suggestion works. Try it.

The -C option is defeated by your use of full path names. If you need to extract with relative path names, you should use the following command to take your backup.

[tt]tar -cvf /dev/rmt/0 -C / ./etc ./ksfc1 ./ksfc2[/tt]
Annihilannic.
 


Thanks Annihilannic..I think thats the problem.I am able to restore the files of /ksfc1 & /ksfc2 with relative path names and not for /etc directory.

I taken backup with

tar -cvf /dev/rmt/0 -C /etc ./ksfc1 ./ksfc2

Anyway thanks for the information given.

Regards

Joe

 
tar -s (in Tru64) removes the leading slash to restore to the current directory path..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top