Skip to main content

compression-patterns

8BitSafe-cli [common options] compression-patterns [sub-command]

Compression patterns give you fine grained control over compression settings when creating an archive.

Instead of using a single compression algorithm for everything we can use patterns to disable or change the compression settings for various files using glob patterns.

This allows us to save time by skipping compression on files that are unlikely to compress further and enable high levels of compression on compressible content like text.

The client ships with a set of compression patterns that are enabled by default, you can view them using the compression-patters default command.

Custom patterns

You can create your own set of compression patterns by defining them in a simple text file and passing to --compression-patterns <path> option when using archive create.

Each pattern should be defined on a separate line starting with the glob pattern followed by the algorithm and an optional level.

See compression for details on supported algorithms, levels and aliases.

note

Patterns are matched against the full path of each file or directory

compression_settings.txt
// <pattern>,<compression>,<compression_level>
// This is a comment
# This is a comment

**,lz4 // set default using catch all **, this overrides cmd line `--compression <algo>` option

// Disable compression for files that are unlikely to compress well.
**.zip,store
**.iso,store
**.jpg,store

**.tar,lz4,fast // use lz4 for uncompressed tar files
**.tar.*,store // any tar file with a dot at the end is likely to be compressed (e.g., tar.gz), so skip compression

**.tga,zstd,slow // use slow compression for tga's

C:\Users\Tom\Documents\**,zstd

Explained

**,lz4

The above sets lz4 as the default, notice we need to use globstar ** instead of a single wildcard * to match all files as explained in glob.

**.zip,store
**.iso,store
**.jpg,store

Disables compression for zip archives, iso and jpg files.
We could also write the above as the following:

**.{zip,iso,jpg},store
**.tar,lz4,fast

Enable lz4 for uncompressed tar files with a different compression level than the default we set above.

**.tar.*,store

Disable compression for compressed tar files as this pattern will match files named files.tar.gz, files.tar.bz2, etc.

**.tga,zstd,slow

For tga images we use zstd in slow mode as they are likely to compress well.

C:\Users\Tom\Documents\**,zstd

Enable zstd for all files under C:\Users\Tom\Documents\ as it likely contains mainly text files which should compress well.