LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar not preserving permissions? (https://www.linuxquestions.org/questions/linux-newbie-8/tar-not-preserving-permissions-730440/)

BassKozz 06-03-2009 11:46 AM

tar not preserving permissions?
 
I backed up using:
Code:

tar -cvpzf foo.tgz .
I restored using:
Code:

tar -C /home/user/restore/ -xvzf foo.tgz
and the permissions aren't kept, what gives?

When I try and run with -p on restore I get:
Code:

tar -C /home/user/restore/ -xvzfp foo.tgz
tar: p: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: /home/user/BACKUPS/foo.tgz: Not found in archive
tar: Error exit delayed from previous errors

p.s. I transfered the backup from one computer to another (different users).

TiA,
-BassKozz

noctilucent 06-03-2009 11:53 AM

Hello.

When you are extracting you are omitting the "p" option.

emmalg 06-03-2009 11:56 AM

Hi

You need to use the p option in the extraction to preserve the archived permissions
Code:

tar -C /home/user/restore/ -xvpzf foo.tgz
Hope this helps, if not, please provide more detail about the permissions, owner and group settings for the files with
Code:

ls -l
.

Cheers
Emma

noctilucent 06-03-2009 12:03 PM

Code:

tar xvfp foo.tgz -C /home/user/restore/

i92guboj 06-03-2009 12:04 PM

Quote:

Originally Posted by BassKozz (Post 3561864)
I backed up using:
Code:

tar -cvpzf foo.tgz .
I restored using:
Code:

tar -C /home/user/restore/ -xvzf foo.tgz
and the permissions aren't kept, what gives?

When I try and run with -p on restore I get:
Code:

tar -C /home/user/restore/ -xvzfp foo.tgz
tar: p: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: /home/user/BACKUPS/foo.tgz: Not found in archive
tar: Error exit delayed from previous errors

p.s. I transfered the backup from one computer to another (different users).

TiA,
-BassKozz

-f is the last. Whatever there is after that is supposed to be the file name.

BassKozz 06-03-2009 12:23 PM

Quote:

Originally Posted by i92guboj (Post 3561880)
-f is the last. Whatever there is after that is supposed to be the file name.

That was it... {DOH} :o
Thanks i92guboj. :D
Quote:

Originally Posted by noctilucent (Post 3561877)
Code:

tar xvfp foo.tgz -C /home/user/restore/

Interestingly enough "f" doesn't have to be last if you don't use a dash.

For Example:
tar xvfp foo.tgz = WORKS
tar -xvfp foo.tgz = DOES NOT WORK
tar -xvpf foo.tgz = WORKS

Wounder why that is?

noctilucent 06-03-2009 12:36 PM

From "tar.c" [GNU Tar 1.22]:

Code:

static void
decode_options (int argc, char **argv)
{
  /* -- code removed [noctilucent] -- */

  /* Convert old-style tar call by exploding option element and rearranging
    options accordingly.  */

  if (argc > 1 && argv[1][0] != '-')
    {

  /* -- code removed [noctilucent] -- */



All times are GMT -5. The time now is 08:41 PM.