Question says it all: I have a directory that I want to 'zip -rv' up, but the files are changing all of the time (postgres database base backup). Will this break zip, or will it continue with a warning, like rsync does?

Tar fails when it finds a file that is changed during compression. I've run a few test zips on the directory while generating file changes, and I haven't seen any errors, but that might just be 'cause I got lucky and zip had already compressed/not yet gotten to the changed files. My plan B at this point is to rsync the changing directory to a different folder and then zip the static location up, but that'll take up twice the space, and I'd like to avoid that if possible. If zip can't handle file changes during compression, is there a utility that does?

OS is centos 6, fwiw.

1 Answer 1


It doesn't handle them at all. zip reads the entire directory tree when it starts creating the archive.

  • If a file is deleted during the zip operation, you'll get a warning message.
  • If a file is created during the zip operation, it won't be in the archive if it was created in a directory that was already read. If the file is created before zip reads that directory's contents, it'll be in the archive.
  • If a file is changed during the zip operation, its contents will be whatever they were when it was added to the archive. Files are read as they are added to the archive.
  • If you want to handle this robustly, I'd suggest rsyncing the directory you want to archive to a separate, copy location, and then zipping that up, verifying, and deleting the copy dir. At least then you know there aren't going to be failures during the archiving process, which can be very costly if you're archiving a big directory.
    – Zac B
    Aug 7, 2012 at 21:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .