Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am writing a small personal archiving tool. I frequently work with a lot of client databases for short periods, what my tool will do is in overnight batch jobs it will detach the database and zip up the database files and any extra files that where sitting in the folder that the database resided in and move it to a network storage drive.

My question is quite frequently there will be zip files sitting inside the folder (the most common one would be the client's original backup before I did the processing on it). Would it be better to unzip the file to a unique sub-folder name, delete the zip, then compress the whole parent folder, or are compression algroithoms good enough that I could leave the file zipped (it was likely done with a 7zip Fastest setting) and my archiving (which will be a 7zip Ultra setting) will just compress (mostly) the difference between the two compression levels?

If I can get another 1% off of a 20GB database file it may be worth it to do the decompression.

share|improve this question
1  
Have you done some experimentation, maybe on two or three folders? My guess is that you'd get better compression with your suggested additional handling, but I'm very far from being sure. –  David Thornley Dec 19 '11 at 18:13
    
@DavidThornley I have not had not tried anything I am still on the "On the whiteboard" phase, so I was hoping someone would have experience with this. I actually have a few ideas, I may unzip everything and use ImageX for de-duplication with /compress maximum –  Scott Chamberlain Dec 19 '11 at 18:33

3 Answers 3

If saving a 1% is really that important, you will test and measure. It's the only way to know if it work out to your advantage for the specific files you are dealing with (you could even also have your program try both and keep the smallest version, therefore ensuring you always pick the most optimum solution wrt. to size).

If not, I'd just do the simpler thing.

share|improve this answer

You will get better compression by decompressing the zip files first. Compressing already compressed data will almost never decrease the size significantly, even if it was previously compressed by a "worse" compression program.

share|improve this answer

Compressing a zip file often results in a larger image, because of the associated overhead and incompressibility. If size is the primary consideration, you will almost always be better off by decompressing it first. However, if that's the case and the zip files are usually nothing more than previous backups, I would seriously look into seeing if they're safe to omit from your archive, or at least back it up fully once then omit it from future backups unless it has changed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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