1824179 Members
4631 Online
109669 Solutions
New Discussion юеВ

Restoring fun with tar

 
Terrence
Regular Advisor

Restoring fun with tar

Hey everyone, my brain is seizing because I've got a legacy system (and backup script) which creates a snapshot of a directory (/app/data) and then tars it off to tape. The problem is that the snapshot is renamed /data.backup. Tar wants to restore to /data.backup and I want it to restore to /app/data. Ideas?
10 REPLIES 10
Sanjay_6
Honored Contributor

Re: Restoring fun with tar

Hi Terry,

I've never tried to restore a tar archive backed up using absolute path to a different location. Had tried long time back and was unsuccessful. Try this link and look at the suggestions from harry and james,

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

Hope this helps.

Regds
MANOJ SRIVASTAVA
Honored Contributor

Re: Restoring fun with tar

Hi Terry

Unfortunately tar doesnt let go the way is was backed up , so if the path it was written was /data.backup , it will restore it as /dat.backup only . There are two ways to overcome this .

1. Store it with the absulte path if you can do it on the legacy systems , ie either use /app/data or just th files under this directory .

cd /app/data
tar cvf /dev/rmt/0m *

and then resoter it by going unde/app/data and then doing a tar xvf .

Or the harder way is to restore it /data.backup and then move the files.


Manoj Srivastava
Patrick Wallek
Honored Contributor

Re: Restoring fun with tar

Have a look at the 'pax' command (man pax for more info.). I think it will do what you what.

The option you specifically need to look at is the '-s' option to pax.

There are examples towards the end of the man page on how to use the '-s' option when restoring files.
Jeff Schussele
Honored Contributor

Re: Restoring fun with tar

Hi Terry,

Check this link & Harry's suggestion of using pax to get around the absolute path tar problem:

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

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Rodney Hills
Honored Contributor

Re: Restoring fun with tar

I believe Gnu tar can do a relative restore of an absolute tar save. You can get a copy from

http://hpux.cs.utah.edu/

-- Rod Hills
There be dragons...
Terrence
Regular Advisor

Re: Restoring fun with tar

Okay that was so fast it was scary, but we think we found the simplest way yet. Let me know what you think. Remember the original directory was /app/data, and the snapshot was named /data.backup.

cd /app
ln -s data data.backup
tar -xvf /dev/rmt/0m data.backup

rm data.backup

Elegant and simple? Or doomed to failure. Points for opinions
Tom Danzig
Honored Contributor

Re: Restoring fun with tar

You can restore a tar archive with absolute pathnames to relative pathnames with pax:

pax -rv -s'/^\///' < /dev/rmt/0m

(Assuming your tape drive is /dev/rmt/0m)

This will restore the archive relative to your current directory location.
Patrick Wallek
Honored Contributor

Re: Restoring fun with tar

It depends entirely on how the tar archive was created.

Was it created with the directory specified as /data.backup or ./data.backup?

There is a VERY BIG difference.

If it was created with /data.backup then you could possibly create a link from /data.backup to /app/data.

If it was created with ./data.backup then the scenario you outlined may work.

As with many things in Unix. It depends.....
MANOJ SRIVASTAVA
Honored Contributor

Re: Restoring fun with tar

Hi Terry

Like Partick said it depends on how it was stored. Also if both the paths are under the same mounpoint possible you can just mv it after the restore.


Manoj Srivastava
Terrence
Regular Advisor

Re: Restoring fun with tar

Yep the tar was done with ./data.backup, so with two lukewarm recommendations away we go and wish us luck! Now everyone out of the pool, this topic is done!