2

I have a file system backup in a tar archive, created with:

cd / && tar -cpz -f mybackup.tgz usr/local

Doing a

tar tvzf mybackup.tgz 

yields:

-rw-rw-r-- otto/otto      450 2010-04-15 22:08 usr/local/alpha-4.5/pkg/conf/PLATFORM/sparc
drwxr-xr-x otto/otto        0 2009-04-01 08:08 usr/local/alpha-4.5/pkg/ui/
drwxr-xr-x otto/otto        0 2009-04-01 08:08 usr/local/alpha-4.5/pkg/ui/src/
drwxr-xr-x otto/otto        0 2009-04-01 08:08 usr/local/alpha-4.5/pkg/ui/src/thyc/
-rw-r--r-- otto/otto     2416 2001-01-13 16:01 usr/local/alpha-4.5/pkg/ui/src/thyc/vid45
-rw-r--r-- otto/otto      569 2001-01-13 16:01 usr/local/alpha-4.5/pkg/ui/src/thyc/vid46

however, extracting like this:

tar xvpz -f mybackup.tgz 

results in the following permissions:

snip...

-rw-rw-r-- 4 otto otto  450 2010-04-15 22:08 usr/local/alpha-4.5/pkg/conf/PLATFORM/sparc
drwx------ 4 root root  4.0K 2011-03-27 23:20 usr/local/alpha-4.5/pkg/ui/
drwxr-xr-x 7 otto otto  4.0K 2009-04-01 08:08 usr/local/alpha-4.5/pkg/ui/src/
drwxr-xr-x 7 otto otto  4.0K 2009-04-01 08:08 usr/local/alpha-4.5/pkg/ui/src/thyc/
-rw-r--r-- 4 otto otto  2416 2001-01-13 16:01 usr/local/alpha-4.5/pkg/ui/src/thyc/vid45
-rw-r--r-- 4 otto otto  569 2001-01-13 16:01 usr/local/alpha-4.5/pkg/ui/src/thyc/vid46

...snip

Notice the second line. For some reason, the directory is now owned by root and the permissions have changed to 700. Its children, who have the same original permissions as their parent, are created with the correct permissions. This is just an excerpt, this is all over the place in the extracted backup.

What could cause this?

Thanks!

5
  • Are you using the same version of tar to backup and restore? Are your source and destination arches the same, or different? Mar 27, 2011 at 23:17
  • Yes, same machine, same tar. The archive is only about a month old. Mar 27, 2011 at 23:42
  • Are you running this as root?
    – Andrew
    Mar 28, 2011 at 3:21
  • Yes, I am running this as root. Mar 28, 2011 at 7:39
  • If you create the archive with tar zcvf, does the output look correct? You don't need the p flag when creating the archive. What filesystem is it?
    – MattBianco
    Mar 31, 2011 at 13:03

1 Answer 1

3

Sounds like a bug in tar to me. Which version are you using? If it's GNU tar you can find out with tar --version. The NEWS file for GNU tar version 1.24 mentions some fixes for bugs relating to permissions, which could be the problem.

1
  • I also noticed one thing while testing a lot of combinations of tar 1.15 an 1.23: The wording in the bug report gives the impression that it affects unpacking only, not the packing ... but my testing shows that packing is also affected. That is, files tar:ed with 1.15 will don't get their original owner (nor permissions, I believe) even if unpacked with tar newer 1.23. Jun 9, 2011 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .