I have a zip file that I use as a backup for my work. I use the "freshen" option (-FS
) whenever I want to update my backup file. However, the file shows the date of last modification as being the date I originally created the file, rather than any of the several times since I have "freshened" the file. Is this normal behavior?
1 Answer
Unix doesn't have a create date, so when you update these files in your .zip
you're updating them based on their modification date, which according to the zip
man page is normal behavior.
excerpt
The new File Sync option (-FS) is also considered a new mode, though it
is similar to update. This mode synchronizes the archive with the files on
the OS, only replacing files in the archive if the file time or size of the
OS file is different, adding new files, and deleting entries from the
archive where there is no matching file. As this mode can delete entries
from the archive, consider making a backup copy of the archive.
Example
Say we have the following 3 files:
$ touch file1 file2 file3
We add them to a ZIP file.
$ zip file.zip file{1..3}
adding: file1 (stored 0%)
adding: file2 (stored 0%)
adding: file3 (stored 0%)
Some time passes and file3
gets updated.
$ touch file3
Now we update the ZIP file.
$ zip -FS file.zip file{1..3}
updating: file3 (stored 0%)
Checking the ZIP file we see the times for the files is now like so:
$ unzip -l file.zip
Archive: file.zip
Length Date Time Name
--------- ---------- ----- ----
0 07-12-2014 02:59 file1
0 07-12-2014 02:59 file2
0 07-12-2014 03:00 file3
--------- -------
0 3 files
If we create a temporary directory and unpack the ZIP file within:
$ mkdir temp; cd temp
$ unzip ../file.zip
Archive: ../file.zip
extracting: file1
extracting: file2
extracting: file3
The contents of this directory are as follows:
$ ls -l
total 0
-rw-rw-r--. 1 saml saml 0 Jul 12 02:59 file1
-rw-rw-r--. 1 saml saml 0 Jul 12 02:59 file2
-rw-rw-r--. 1 saml saml 0 Jul 12 03:00 file3
And if we use the stat
command to check out file3
:
$ stat file3
File: ‘file3’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd02h/64770d Inode: 17307675 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ saml) Gid: ( 1000/ saml)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2014-07-12 03:00:16.000000000 -0400
Modify: 2014-07-12 03:00:16.000000000 -0400
Change: 2014-07-12 03:01:03.447913554 -0400
Birth: -
NOTE: Notice there is timestamps for access, modify, and change. The zip
command is preserving the access and modify times when you use the -FS
switch.
References
-
So,
-FS
will update the timestamp of the individual files in the .zip file while the .zip file's own timestamp remains unchanged? Jul 13, 2014 at 15:09 -
@Joshua - no it's not possible to preserve the timestamp of the .zip file itself. Anytime you manipulate it, you're modifying the timestamp.– slm ♦Jul 13, 2014 at 15:22
-
I'm not asking because I want to preserve the timestamp, I'm asking because the timestamp of my
.zip
file does not update after I use the-FS
flag. Jul 14, 2014 at 22:28