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

From: Daniel Tameling <tamelingdaniel_at_gmail.com>
Date: Fri, 02 May 2025 12:53:52 UTC
On Thu, May 01, 2025 at 05:04:12PM +0200, Matthias Apitz wrote:
> 
> Hello,
> 
> I do backups with something like 'tar cfz home.tgz home' and today due
> to an emergency I was lucky to have such backups and did a restore with
> something like 'tar xzf home.tgz'. I was suprised that now all
> diretories have the today modificatguru/Adaion time, like this:
> 
> $ ls -ld Ada
> drwxr-xr-x  2 guru wheel 512  1 may.  11:31 Ada
> $ ls -l  Ada
> total 1008
> -rwxr-xr-x  1 guru wheel 977936 27 feb.   2016 hello
> -rw-r--r--  1 guru wheel    124 27 feb.   2016 hello.adb
> -rw-r--r--  1 guru wheel   1630 27 feb.   2016 hello.ali
> -rw-r--r--  1 guru wheel   1608 27 feb.   2016 hello.o
> -rw-r--r--  1 guru wheel    120 27 feb.   2016 hello.txt
> 
> In the tar archive the directory 'Ada' looks like this:
> 
> $ grep guru/Ada guru-20250501.tar.gz.lst
> drwxr-xr-x  0 guru   wheel          0  8 Dez.  2020 guru/Ada/
> -rw-r--r--  0 guru   wheel        124 27 Feb.  2016 guru/Ada/hello.adb
> -rw-r--r--  0 guru   wheel       1630 27 Feb.  2016 guru/Ada/hello.ali
> -rw-r--r--  0 guru   wheel       1608 27 Feb.  2016 guru/Ada/hello.o
> -rwxr-xr-x  0 guru   wheel     977936 27 Feb.  2016 guru/Ada/hello
> -rw-r--r--  0 guru   wheel        120 27 Feb.  2016 guru/Ada/hello.txt
> 
> Why is the directory guru/Ada/ not set to 8 Dez.  2020 after restoring
> the files into it? Is this a bug in our bsdtar?
> 
> Thx
> 
> 	matthias
> 
> 
> -- 
> Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
> Public GnuPG key: http://www.unixarea.de/key.pub
> 
> An die deutsche Bundesregierung: Nein, meine Söhne geb' ich nicht für Ihren Krieg!
> Al Gobierno alemán: ¡No, no doy mis hijos para su guerra!
> To the German Government: No, I will not give my sons for your war!
> 

Hi,

GNU tar has an option to deal with this:

       --delay-directory-restore
              Delay setting modification times and permissions of extracted
              directories until the end of extraction.  Use this option when
              extracting from an archive which has unusual member ordering.

It is available as the gtar command if you install the gtar package. 

--
Best regards,
Daniel