1834021 Members
2319 Online
110063 Solutions
New Discussion

Re: Tar extraction fails

 
P_F
Regular Advisor

Tar extraction fails

While attempting to extract a tar file from

/home/y7p/file.tar

to

/production/Y7P

the operation fails. There is no error message.

Here is the cmd:

$ tar xvf /home/y7p/file.tar /production/Y7P

If I mv or cp the file to /production/Y7P and then untar the operation works.

Note:

1)
I am performing this as user y7p

2)
Here is some info from /etc/fstab

/dev/vgtools/prod /production vxfs rw,suid,largefiles,delaylog,datainlog 0 2

/dev/vgtools/prod_Y7P /production/Y7P vxfs rw,suid,largefiles,delaylog,datainlog 0 2

/dev/vg00/lvol5 /home vxfs delaylog 0 2

3) Here are relevent directory perms

drwxrwxrwx+ 4 root root 96 Jun 27 17:11 /production

# getacl /production
# file: /production
# owner: root
# group: root
user::rwx
user:y7p:rwx
group::rwx
group:users:rwx
class:rwx
other:rwx

AND


drwxrwxr-x+ 10 y7p users 1024 Jun 27 17:15 /production/Y7P

# getacl /production/Y7P
# file: /production/Y7P
# owner: y7p
# group: users
user::rwx
user:y7p:rwx
group::rwx
group:users:rwx
class:rwx
other:r-x
default:class:rwx
default:other:rwx
14 REPLIES 14
Tim Nelson
Honored Contributor

Re: Tar extraction fails

syntax is wrong.
tar xvf /home/y7p/file.tar /production/Y7P

with try to extract a file / directory called /production/Y7P

You cannot do redirection with tar.

If the tar file was created relative then you can change directories and have the structure beneath. If the tar was created absolute you have no choice, it will have to be untar'd to the path it was tar'd with.

tar vtf /home/y7p/file.tar will show you the contents and paths.
Tim Nelson
Honored Contributor

Re: Tar extraction fails

Sorry,
My assumption was you are attempting a redirect, perhaps you really do want the one directory restored.

If you are looking for a specific file/dir the selection must match exactly what is in the tar file. tar vtf file.tar to see the contents. The extraction is not finding what you have told it to look for.

P_F
Regular Advisor

Re: Tar extraction fails

Hello:

I'm trying to untar the contents of file.tar, which includes a number of different subdirectories and files.

Here is a session:

DMC2 root@pkdh0085 [/root]
# su - y7p

DMC2 y7p@pkdh0085 [/home/y7p]
$ whoami
y7p

DMC2 y7p@pkdh0085 [/home/y7p]
$ ls
profile.back spam.txt
restoreResultProcessor-production-27.tar y7p

DMC2 y7p@pkdh0085 [/home/y7p]
$ tar xvf restoreResultProcessor-production-27.tar /production/Y7P

DMC2 y7p@pkdh0085 [/home/y7p]
$

Tim Nelson
Honored Contributor

Re: Tar extraction fails

execute a tar vtf /home/y7p/file.tar and post the results. If too long then tar vtf /home/y7p/file.tar |grep Y7P


1 of 2 things. There is nothing in the tar file relevant to /production/Y7P or the tar was created with relative path and the command should be tar xtf /home/y7p/file.tar production/Y7P

The content listing will determine the course.
P_F
Regular Advisor

Re: Tar extraction fails

DMC2 [/home/y7p]
$ tar vtf /home/y7p/restoreResultProcessor-production-27.tar
rwxrwxrwx 0/0 0 Jun 27 16:38 2007 y7p/essrestore/
rwxrwxrwx 0/0 0 Jun 27 16:38 2007 y7p/essrestore/etc/
rwxrwxrwx 0/0 0 Jun 27 16:38 2007 y7p/essrestore/lib/
rwxrwxrwx 0/0 0 Jun 27 16:38 2007 y7p/essrestore/scripts/
rwxrwxrwx 0/0 684 Jun 27 16:38 2007 y7p/essrestore/etc/essRestore.cfg
rwxrwxrwx 0/0 1061 Jun 27 16:38 2007 y7p/essrestore/etc/log4j.properties
rwxrwxrwx 0/0 45386 Jun 27 16:38 2007 y7p/essrestore/lib/activation.jar
rwxrwxrwx 0/0 63980 Jun 27 16:38 2007 y7p/essrestore/lib/commons-lang-1.0.1.jar
rwxrwxrwx 0/0 38015 Jun 27 16:38 2007 y7p/essrestore/lib/commons-logging-1.0.4.jar
rwxrwxrwx 0/0 350627 Jun 27 16:38 2007 y7p/essrestore/lib/log4j-1.2.11.jar
rwxrwxrwx 0/0 280984 Jun 27 16:38 2007 y7p/essrestore/lib/mail.jar
rwxrwxrwx 0/0 7022 Jun 27 16:38 2007 y7p/essrestore/lib/restoreResult.jar
rwxrwxrwx 0/0 179 Jun 27 16:38 2007 y7p/essrestore/scripts/findRstrCDRCnt.sh
rwxrwxrwx 0/0 696 Jun 27 16:38 2007 y7p/essrestore/scripts/restoreResult.sh
rwxrwxrwx 0/0 84 Jun 27 16:38 2007 y7p/essrestore/scripts/runAglntEssRestore.sh
rwxrwxrwx 0/0 7188 Jun 27 16:38 2007 y7p/essrestore/scripts/y7pEssRestore.sh
Tim Nelson
Honored Contributor

Re: Tar extraction fails

There is no /production/Y7P directory in your tar listing so the extract cannot find what you asked for and hence no extract or output.

Your listing shows a relative tar of y7p subdirectory ( notice the case as well )

If this is what you are looking for and you wish to extract into /production then:

cd /production
tar xvf source.tar y7p
P_F
Regular Advisor

Re: Tar extraction fails

Hello Tim:

Thanks for your kind assistance.

In this case I'm attempting to create a sub directory y7p/ in the /production/Y7P/

Are you saying my cmd line for tar is incorrect?

$ tar xvf /home/y7p/file.tar /production/Y7P
(or from /home/y7p )

$ tar xvf file.tar /production/Y7P
P_F
Regular Advisor

Re: Tar extraction fails

One more question...

Would it matter that this mount point is a SAN?
Tim Nelson
Honored Contributor

Re: Tar extraction fails

The type of disk supporting the directory makes no difference.

Here is the point.

There is no redirection in tar. The argument after the source file specifies a particular file or directory that is in the tar file not a destination for the extract.

In your case you will have to extact the lowercase y7p as it is then move then either rename the directory or move your newly extacted files to the directory of your choosing.

Patrick Wallek
Honored Contributor

Re: Tar extraction fails

No the mount point does not matter.

Yes, your syntax is incorrect.

To do what you want to do:

# cd /production/Y7P
# tar -xvf /home/y7p/file.tar

That will extract the entire contents of your tar file into your current directory. This should solve your problem.

The problem with your syntax is that where you were specifying the /production/Y7P is where tar expects to find the files to extract. Since /production/Y7P doesn't exist in the tar file, it failed.
P_F
Regular Advisor

Re: Tar extraction fails

Thanks guys, that must be it. I guess I just didn't understand the execution of tar.

I thought when I executed:

tar ./file.tar /some/directory/path/

it would work.

Curiously, it works when I use

tar ./file.tar /some/other/directory/path/
Dennis Handly
Acclaimed Contributor

Re: Tar extraction fails

>Tim: There is no redirection in tar.

You can "redirect" on create:
$ tar -cvf file.tar -C pathx a1 a2

The files a1 and a2 are relative to pathx.

pax(1) will allow you to change the paths on extraction.
P_F
Regular Advisor

Re: Tar extraction fails

I'll try this later today, Dennis.
P_F
Regular Advisor

Re: Tar extraction fails

Ok, here's the deal. I think I got it now, when the tar file was created it did not contain the absolute path starting at the mount point in question.

Though its relative path is correct, when I extract it, as Patrick said, "the problem is that where you were specifying the /production/Y7P is where tar expects to find the files to extract. Since /production/Y7P doesn't exist in the tar file, it failed." That is /production wasn't in the paths in the tar file.

As a note... the reason why I said I could extract to other mount points is because the tar file I used to test this operation did not include relative paths, but a singl simple, since I didn't want to dump a sensitive tar file throughout the system.

As as second note... I'm pretty sure that GNU tar supports this sort of activity, and I think that was the source of my confusion.

Thanks for the help my hope is others may find this example useful.