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!

restore from tar file syntax problem 1

Status
Not open for further replies.

frumpus

Programmer
Aug 1, 2005
113
US
We are setting up a new server and before we get too far we want to test a backup and restore. I don't have the tape drive in yet, so I backed the system up to the hard drive in a tar file (uncompressed.)

Now I want to restore it to a temp directory I've created just to make sure we can do that and that everything is there.

I am attempting to do so with this command:

Code:
sudo tar -xvf /rman/test_restore/full_backup_09-JUN-2011 /rman/backup_initial_full/full_backup.tar

/rman/test_restore/full_backup_09-JUN-2011 is a directory I created to restore the tar into.

When I try to run this I get the error:

Code:
tar: /rman/test_restore/full_backup_09-JUN-2011: Cannot read: Is a directory

Then it gives up. Did I leave something out to tell it that yes that is a directory and that's where I want it to put the files? I don't want to randomly try things and overwrite the existing system so I need to get this right.
 
You are providing the directory as a parameter to the -f option, which is expecting the tar file.

Try this:

Code:
tar -xvf /rman/backup_initial_full/full_backup.tar -C /rman/test_restore/full_backup_09-JUN-2011

Or this:

Code:
tar -xvfC /rman/backup_initial_full/full_backup.tar /rman/test_restore/full_backup_09-JUN-2011

The latter demonstrates tar's weird behaviour of accepting parameters to its options (in the same order) after all of the options have been specified.

Annihilannic.
 
A word of warning - watch out for absolute pathnames when playing with tar!

The internet - allowing those who don't know what they're talking about to have their say.
 
Ken, would you elaborate on that a bit? What am I watching out for?
 
Hi. Apologies - the weekend intervened! Basically, tar normally writes files with the absolute pathname - ie the full /back/to/root path. When these are restored using tar, they are written to the exact place they were written from, and sometimes this is not desirable (for example if one wants to compare an older copy of a file with the current one).

To avoid this you can use pax:
Code:
pax -r -s,/export/home/users,/export/home/users2, -f /tmp/users.tar

will extract files from users.tar changing /export/home/users to /export/home/users2

Hope this helps.



The internet - allowing those who don't know what they're talking about to have their say.
 
Hi Frumpus. Just remembered that we're dealing with Linux here, not Solaris, so it could be that your tar (possibly GNU?) will exhibit different behaviour. To find out, use:

tar -tvf filename.tar

just to list the files in the archive (and how they are referenced) rather than actually extract them. Apologies for any confusion!

The internet - allowing those who don't know what they're talking about to have their say.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top