bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unpreserved modification time using `-g snapshot-file'


From: Wolfgang Molzer
Subject: Unpreserved modification time using `-g snapshot-file'
Date: Mon, 05 May 2003 18:37:40 +0200

Hello,

Using `-g snapshot-file' option at creation time of the archive prevents
the archived modifications times (seen with -t) of non-empty
subdirectories to be restored after extraction.  (Without this option
the mod time stamps of the extracted directories are the same as the
archived ones.)

I am not really sure if this is to be considered a bug.  I any case i
think it is counter-intuitive.  Using the `-g snapshot-file' option is
intended to be used for incremental backups/restores, right.  I think in
this case a timestamp reflecting the contents of the archive is
especially important.

To see what i mean, create some short file-tree like the following
(touch the files/dirs/... to give them some past date).

wilma:~/tmp,1,387> find gtar.test -exec ls -ld {} \;
drwxr-x---   3 molzer     hlsim           96 May  5 17:55 gtar.test
drwxr-x---   3 molzer     hlsim           96 May 23  2001 gtar.test/dir
drwxr-x---   2 molzer     hlsim           96 May 23  2001 gtar.test/dir/subdir
-rw-r-----   1 molzer     hlsim            0 May 23  2001 
gtar.test/dir/subdir/empty
-rw-r-----   1 molzer     hlsim            0 May 23  2001 gtar.test/dir/empty

Then try to migrate it to gtar.test2 like with the help of the following
sh-script (located for the example in ~/tmp; the intended application is
to move a home directory of 13GB and wanted to use a similar script!).

# BEGIN script

tarfile=-
snapshot=""
for arg in $*; do
    case $arg in
        -exec)  cmd=""; shift;;
        -g)     snapshot="-g";  snapshotargs="$snapshot 
`pwd`/modtime.snapshot"; shift;;
        -f)     tarfile="`pwd`/modtime$snapshot.tar"; shift;;
    esac
done

snapshot=migrate.snapshot
sourcedir=`pwd`/gtar.test
targetdir=${sourcedir}2
echo "migrate \"$sourcedir\" --> \"$targetdir\""
psourcedir=`dirname $sourcedir`
ptargetdir=`dirname $targetdir`

if ! test -d $sourcedir
then
    echo "no directory: $sourcedir"
    exit 2
fi

if ! test -d $ptargetdir
then
    echo "no directory: $ptargetdir"
    exit 2
fi

if ! test -d $targetdir
then
    $cmd mkdir $targetdir
fi

if [ $tarfile = - ]; then
    case $cmd in
        echo)   $cmd "cd $sourcedir; gtar -cvf $tarfile $snapshotargs . | (cd 
$targetdir; gtar -xvf $tarfile $snapshotargs)";;
        *)            cd $sourcedir; gtar -cvf $tarfile $snapshotargs . | (cd 
$targetdir; gtar -xvf $tarfile $snapshotargs);;
    esac
else
    case $cmd in
        echo)   $cmd "cd $sourcedir; gtar -cvf $tarfile $snapshotargs .; cd 
$targetdir; gtar -xvf $tarfile $snapshotargs";;
        *)            cd $sourcedir; gtar -cvf $tarfile $snapshotargs .; cd 
$targetdir; gtar -xvf $tarfile $snapshotargs;;
    esac
fi

# END script

Attention: gtar is GNU tar in this script

wilma:~/tmp,0,389> gtar --version
tar (GNU tar) 1.13.25
Copyright (C) 2001 Free Software Foundation, Inc.
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by John Gilmore and Jay Fenlason.

If i use the script without the -g, the modification time stamps of the
extract are what i expect them.  With -g (after removal of gtar.test2
certainly) the subdirectory dir/subdir has the current timestamp.
(Funnyly without files in the directory this changes, but i did not
follow the details too deep).

wilma:~/tmp,0,395> find gtar.test2 -exec ls -ld {} \;
drwxr-x---   3 molzer     hlsim           96 May  5 18:13 gtar.test2
drwxr-x---   3 molzer     hlsim           96 May 23  2001 gtar.test2/dir
drwxr-x---   2 molzer     hlsim           96 May  5 18:13 gtar.test2/dir/subdir
-rw-r-----   1 molzer     hlsim            0 May 23  2001 
gtar.test2/dir/subdir/empty
-rw-r-----   1 molzer     hlsim            0 May 23  2001 gtar.test2/dir/empty

One can use the -f switch of the script (preceeding -g!) to look into
the archives, this is what i find

wilma:~/tmp,0,416> gtar -tvf modtime-g.tar
drwxr-x--- molzer/hlsim      6 2003-05-05 18:21:42 ./
drwxr-x--- molzer/hlsim     16 2001-05-23 19:51:35 ./dir/
drwxr-x--- molzer/hlsim      8 2001-05-23 19:51:35 ./dir/subdir/
-rw-r----- molzer/hlsim      0 2001-05-23 19:51:35 ./dir/empty
-rw-r----- molzer/hlsim      0 2001-05-23 19:51:34 ./dir/subdir/empty
wilma:~/tmp,0,417> gtar -tvf modtime.tar
drwxr-x--- molzer/hlsim      0 2003-05-05 18:21:42 ./
drwxr-x--- molzer/hlsim      0 2001-05-23 19:51:35 ./dir/
drwxr-x--- molzer/hlsim      0 2001-05-23 19:51:35 ./dir/subdir/
-rw-r----- molzer/hlsim      0 2001-05-23 19:51:34 ./dir/subdir/empty
-rw-r----- molzer/hlsim      0 2001-05-23 19:51:35 ./dir/empty

The timestamps seem what i expected them before i saw the extracted
archive.  Is this a behavior to be expected, if so what is the reasoning
-- i can't find details about this in the info-pages?  Or is there just
a little confusion in the order of setting the timestamps?  I have
tested this on HP-UX 11i and Linux 2.4.18-27.8.0smp (RedHat), it's the
same.

Thanks for help,
Wolfgang Molzer

--
================================================================
Wolfgang Molzer         Senior Staff Engineer Technology CAD
Mail:                      |   Phone: +49 89 234 42232
 Infineon Technologies AG  |   Fax  : +49 89 234 45411
 CL TD SIM                 |   email: address@hidden
 D-81730 Munich            |
 Germany                   |
================================================================


Attachment: wolfgang.molzer.vcf
Description: Card for Wolfgang Molzer


reply via email to

[Prev in Thread] Current Thread [Next in Thread]