Estimate .tar.gz file size before compression

We are working on a system (on Linux) that has very limited transfer resources. The maximum file size that can be sent as a single file is determined, and we would like to send the minimum number of files. Because of this, all sent files are packed and compressed in the GZip format (.tar.gz).

There are many small files of various types (binary, text, images ...) that need to be packed in the most efficient way to send the maximum amount of data each time.

The problem is this: is there a way to estimate the size of the tar.gz file without running the tar utility? (Thus, the best combination of files can be calculated)

+4
source share
2 answers

It depends on what you mean by โ€œsmall files,โ€ but actually not. If you have a large file that is relatively homogeneous in its contents, you can compress 100K or 200K from the middle and use the compression ratio as an estimate for the rest of the file.

For files about 32 thousand or less in size, you need to compress them to see how large they are. Also, when you combine many small files in a tar file, you will get better compression in general than individually for small files.

, , , " ". tar ( ). . .

, , .

+3

, tar .

tar -czf - /directory/to/archive/ | wc -c 

: wc, , . . , .

: Ultimate Tar Command 10

0

Source: https://habr.com/ru/post/1548200/


All Articles