How to define if a file should be compressed

You can configure the behaviour of storeBackup about compression with a combination of the following options: exceptSuffix, addExceptSuffix, compressSuffix, minCompressSize and comprRule. Please note that option comprRule is generated from the others so you do not have to care about it. However, if you set comprRule, the values of the other options are ignored (only use comprRule if you want to do very fancy stuff).

Using default values:

If you use default values, starting with storeBackup version 3.3 nothing changes to previous versions. The default values are:

exceptSuffix = \.zip \.bz2 \.gz \.tgz \.jpg \.gif \.tiff \.tif \.mpeg \.mpg \.mp3 \.ogg
   \.gpg \.png
addExceptSuffix =
compressSuffix =
minCompressSize = 1024

You can change the value of minCompressSize, change the suffixes of exceptSuffix or add suffixes to addExceptSuffixes. As long as compressSuffix is not set, storeBackup will internally generate a rule with means (with default values):
Do not compress files less than 1k bytes or having one of the suffixes defined in exceptSuffix or defined in addExceptSuffix.

If you do not define exceptSuffix or minCompressSize, the default values will be taken!20

No compression at all:

If the rule comprRule returns 0, the concerned file will not be compressed. So we can configure simply:

comprRule = 0

Compress every file:

If the rule comprRule returns 1, the concerned file will be compressed. So we can configure:

comprRule = 1

But that's not really useful. Why compressing files, which cannot be compressed any more and will therefore be bigger after compression!?

Using a white list and a blacklist:

In most cases, you know some file types (by suffix) you are using not to compress (like .jpg) and others where it makes sense to compress (like .doc, .bmp, .txt, etc.).
If you define one or more suffixes at compressSuffix, e.g., .pdf

compressSuffix = \.pdf

then storeBackup will behave in the following way:
Do not compress files less the value defined in minCompressSize. Do not compress files with suffixes defined in exceptSuffix or addExceptSuffix. Compress files with suffixes defined in comprSuffix. For the rest of the files, make a decision based on COMPRESSION_CHECK.

Let storeBackup decide:

There is a special rule-function which appraises if it is worth to compress a file. This rule-function returns 1 if it thinks the file should be compressed and 0 if not. So we simply define the following comprRule:

comprRule = '&::COMPRESSION_CHECK($file)'

The rule above works pretty well, but often it is not necessary to run this rating and therefore you can simply set the other options and do not have to care about comprRule (which is generated automatically, like described above).

Recommendation

What you should do and what fits in most cases: Depending on your needs, simply define some suffixes for files which should be compressed (comprSuffix) (like .pdf) and maybe extend the list of files with suffixes with should not be compressed (addExceptSuffixes). That's it.

Remark: If you use the ``blocked file''features of storeBackup, you can also use this algorithm by setting e.g., option checkBlocksCompr to check. See blocked files for more information.

Do it your own way

If you have very special demands, e.g., configure everything in the way described above, but do not compress the files for a specific group or some users, you have to (and can) define an individual rule. Do this by using the hints given in section rules and run very small backups with debug level 3 for testing.

Heinz-Josef Claes 2014-04-20