Smaller compressed tar archives
I've seen some benchmarks recently showing just how much smaller 7z compression can be than traditional zip/gzip/bzip. This motivated me to update some regular archiving scripts to switch from gzip compression to 7z.
Normally to create a compressed tar archive under Linux, you do something like this:
tar cvzf <Destination archive>.tar.gz <source folder>
To use 7z instead, you first need to make sure it's installed - which on Ubuntu/Debian based systems you can do as follows:
sudo apt-get install p7zip p7zip-full
Then you can pipe your tar output through 7z:
tar cf - <source folder> | 7z a -mx=9 -si <Destination archive>.tar.7z
It really works! Some of my text-heavy directories were 40% smaller using 7z "Ultra" compression.
The above command uses the following parameters.
tar:
cf -> create archive
- -> output to stdout instead of a file
7z:
a -> Add to archive
-mx=9 -> Use "ultra" compression (slower but smaller)
-si -> Read from stdin instead of from a file/folder.
On unix filesystems, it's recommended to use tar and 7z in combination in this way because 7z by itself will not preserve file permissions and ownership.
Comments
No Comments for this post yet...
Leave a comment
Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>