4

This website about Linux's zip utility says this about the -u flag:

Replace (update) an existing entry in the zip archive only if it has been modified more recently than the version already in the zip archive. For example:

        zip -u stuff * 

will add any new files in the current directory, and update any files which 

have been modified since the zip archive stuff.zip was last created/modified.

My question is, if a particular file has been removed since the last time it was zipped, whether -u will recognize that the file has been removed and thus remove it from the *.zip file? Or, lacking timestamp information (since the file is now removed), it will leave the backed up file in *.zip, since there is no "newer" file?

  • Shouldn't that be really easy to verify? – Adrian Frühwirth Aug 15 '13 at 20:19
6

On zip version 3.0 there is:

   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.

I think that is what you are after?

If you do want to keep files in the archive, then -u does so:

$ mkdir test && touch test/{flibble,foobaz,blurp}
$ zip -r test test
  adding: test/ (stored 0%)
  adding: test/foobaz (stored 0%)
  adding: test/flibble (stored 0%)
  adding: test/blurp (stored 0%)
$ rm test/flibble && touch test/{,flibble}
$ zip -ru test test
updating: test/ (stored 0%)
updating: test/flibble (stored 0%)
$ unzip -l test
Archive:  test.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2013-08-15 22:04   test/
        0  2013-08-15 22:04   test/foobaz
        0  2013-08-15 22:04   test/flibble
        0  2013-08-15 22:04   test/blurp
---------                     -------
        0                     4 files
  • Yes, -FS appears to be what I am after. – NeutronStar Aug 15 '13 at 21:49
  • Grand, I'd appreciate it being marked as the correct answer :) happy zipping :) – Drav Sloan Aug 15 '13 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.