LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-03-2009, 11:46 AM   #1
BassKozz
Member
 
Registered: Dec 2008
Distribution: Ubuntu 8.10
Posts: 35

Rep: Reputation: 15
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

Last edited by BassKozz; 06-03-2009 at 11:56 AM.
 
Old 06-03-2009, 11:53 AM   #2
noctilucent
Member
 
Registered: Jun 2009
Distribution: slackware
Posts: 123

Rep: Reputation: 25
Hello.

When you are extracting you are omitting the "p" option.
 
Old 06-03-2009, 11:56 AM   #3
emmalg
Member
 
Registered: Jun 2009
Location: Spain
Distribution: Various, Ubuntu, Fedora, Open Solaris, Solaris, RHEL, CentOS
Posts: 64

Rep: Reputation: 16
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
 
Old 06-03-2009, 12:03 PM   #4
noctilucent
Member
 
Registered: Jun 2009
Distribution: slackware
Posts: 123

Rep: Reputation: 25
Code:
tar xvfp foo.tgz -C /home/user/restore/
 
Old 06-03-2009, 12:04 PM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,036

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
Quote:
Originally Posted by BassKozz View Post
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.
 
Old 06-03-2009, 12:23 PM   #6
BassKozz
Member
 
Registered: Dec 2008
Distribution: Ubuntu 8.10
Posts: 35

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by i92guboj View Post
-f is the last. Whatever there is after that is supposed to be the file name.
That was it... {DOH}
Thanks i92guboj.
Quote:
Originally Posted by noctilucent View Post
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?

Last edited by BassKozz; 06-03-2009 at 12:30 PM.
 
Old 06-03-2009, 12:36 PM   #7
noctilucent
Member
 
Registered: Jun 2009
Distribution: slackware
Posts: 123

Rep: Reputation: 25
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] -- */

Last edited by noctilucent; 06-04-2009 at 02:15 PM.
 
  


Reply

Tags
permissions, tar


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with tar not preserving owner z01krh Linux - Newbie 13 05-18-2009 01:19 PM
Preserving Permissions RemusX2 Linux - Software 2 07-10-2005 11:20 AM
mv: preserving times / setting permissions (FAT32) Samsara Linux - General 4 01-25-2005 06:57 AM
scp with preserving permissions pradi_net Linux - Software 1 06-08-2004 08:00 AM
Preserving permissions when using cp pilot1 Linux - General 2 08-16-2003 05:29 AM


All times are GMT -5. The time now is 05:06 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration