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!
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.