I have a large compressed .tar.xz
file containing log files. The compression ratio is very good – but it takes a long time to compress, and if I want to add additional log files to it, I have to extract it, add the new file, and recompress it – which takes even longer and uses up a lot of disk space.
Is there an archive/compression method that allows me to efficiently add a new file to an existing archive while still retaining the benefits of solid compression? (i.e. not compressing files on an individual basis, which is what .zip
does).
Best Answer
It is not possible to update or delete files from a solid compression. In a solid compression, the compression of the subsequent data depends on statistical analysis of previous data (which usually brings better compression fine tuning the statistical analysis of the input), hence removing files require un-compression and re-compression of the whole archive containing the files.
It is also important to understand that solid compression is usually used where you want to save disk/bandwidth but don't mind the extra time it takes to compress or decompress and loose the flexibility of updating or editing. there are other tools out there that provide the ability for quick compression/decompression, including updating existing archive but then the compression ratio is not the same as solid compression.
The Solid compression you are referring to "tar.xz" is an "emulated" solid compression"
Let me start by explaining how your currently used method of tar.xz works.
Hence Tar is basically an archive.
Hence when you combine the two you are first Archiving (tar) a number of files and then compressing (xz) that single file.
Now on the question on how can one add new content / update the existing compressed file.
If using tar.xz you will have to uncompress the tar.xz, which will leave you with a tar file and then you can use the following to append the archive.
and then to compress it back again.
Or alternatively, you can use ZIP.