Terminal - Is the built in zip command lossy?

I'm using BASH in the terminal on Yosemite.

Is the zip command lossy?

I'm using it like this

zip -er ./output.zip ./input

-e encrypt

-r recurse

I am trying to avoid lossy compression when backing up data.

Would be super weak sauce if my backups came out corrupt :(


Solution 1:

No, ZIP files are never compressed in a lossy way, nor would it really even be possible.

Lossy compression algorithms only work for data which can be approximated and still be recognizable to humans. Pictures and audio work for this, but not arbitrary data.

ZIP compression algorithms take arbitrary data, and without knowing what it is, compress it losslessly by finding redundant data, and mapping it out. There would be no way to know what part of the data might be approximated, which is why archive software use lossless compression.

Solution 2:

The zip format does not use lossy compression, but the zip command is lossy in a different sense -- it does not include some kinds of Mac-specific file metadata in the archive. The metadata that gets left off is mostly unimportant. I'm talking about things like file tags, Spotlight comments, and such. Mostly.

If that's not good enough for you, you can use ditto, with the appropriate options. Here's an example, taken from the ditto man page:

ditto -c -k --sequesterRsrc --keepParent src_directory archive.zip

Solution 3:

No, all of the compression methods supported in the .zip file format are lossless. See Wikipedia.