Re: restoring a tar archive && modification time of directories

From: Jin Guojun[VFF] <jguojun_at_gmail.com>
Date: Thu, 01 May 2025 18:58:42 UTC
On 5/1/25 11:33, Matthias Apitz wrote:
> I can reproduce the problem with:
>
> $ rm -r d
> $ mkdir d
> $ touch -t 202504300101 d/file d
> $ ls -ld d d/file
> drwxr-xr-x  2 guru wheel 512 30 abr.  01:01 d
> -rw-r--r--  1 guru wheel   0 30 abr.  01:01 d/file
> $ tar cf d.tar d
>
> (without deleting the directory 'd')
>
> $ tar xf d.tar
> $ ls -ld d d/file
> drwxr-xr-x  2 guru wheel 512  1 may.  20:25 d
> -rw-r--r--  1 guru wheel   0 30 abr.  01:01 d/file
>
> i.e. if the directories are existing (as it was in my original case
> restoring into my HOME a backup), the modification time of the directory
> will not be adjusted to the value in the tar archive. One could call
> this a bug or a feature. Don't know.
>
> 	matthias

This is the original "tar" behavior, which does not restore the existing 
directory timestamp.

The "mv" command actually gradually changed behavior on restoring 
timestamp since 12-R, if my memory services correct.

11-R and earlier releases, mv directories to any other location, the 
directory timestamp is intact. "mv" in some 12-R does and some does not.

In 13 and later releases, mv only restores the directory timestamp when 
mv made cross file systems; it moving is made within the same file 
system, the timestamp of the root directory is set to the moving 
date-time, which is kind annoying.

-Jin