extract from tar backup

Hi All,

I have created a tar file by giving the below command :

all files of directory : /Accounts/2001/10/26

$tar -cvf Act26.tar /Accounts/2001/10/26

I copied into another server and given the following command:

$tar -xvf Act26.tar

then permision denied message came due to the above directory not exits in that new server,

my doubt is how to extract the file into required directory without creating the above directory?

Now I am in on-line and waiting for reply...

Please mail me to : ::email removed::

Thanks
krishna

When you make a tar archive and give absolute pathnames as you have done, tar will demand that the files be untarred into the same exact place. So you need to use relative pathnames instead.

cd /Accounts/2001/10
tar -cvf Act26.tar 26
will backup the 26 directory and everything under it.

cd /Accounts/2001/10/26
tar -cvf Act26.tar .
will exclude even the "26" directory and only get the contents in the tarball.

I can't be sure which of these two options you really want.

If you can't recreate the tarball, you may still have some options. I have never used gnutar, but I understand that it has an option for this. Also, maybe you can create /Account/2001 temporarily and then symlink /Accounts/2001/10 to the real directory. Finally, I once used "/usr/sbin/chroot tar xvf xx.tar" when I was in a simliar bind. But it was hard to set up the chroot'ed environment. I had to fiddle with it until it worke

I already answered but my aswer was deleted. Therefore again:

If you already have tar file created with absolute pathnames, try to use GNU tar which has option for removing "leading /".

You can create the same path on the new box, /Accounts/2001/10/26. Untar the tarball, in this directory.

Then use "cp -r" to move recursively from there to where you really want it to go. Actually one way to do this is:

"cp -r sourcedir targetdir && rm -rf sourcedir"

Read "man cp" for more details.

:slight_smile: