Different compression algorithms are supported:
Each algorithm provides several levels of speed/efficiency. The compression algorithm you will use depends on how fast your processor is, how much disk space you have, and how big the archive can be.
All these compression algorithms are implemented in libraries that fsarchiver is using. It means you need these libraries to be installed on your computer to compile fsarchiver with the support for these compression algorithms. gzip, bzip2 and xz are very common so it must not be a problem. lzo is not always installed so you may have to install it, or to disable support for it. lz4 has become popular and should be available in all recent distributions. Also zstd is quite recent but very popular and well supported in recent Linux distributions, but it may not have an official package in older distributions.
fsarchiver is able to do multi-threading. Unlike many compression programs that can use only one cpu core, fsarchiver can use all the power of your system. It means that it can compress about four times faster on a computer with a quad-core processor for instance.
By default, fsarchiver just creates one compression threads, so it just uses one processor core. To enable the multi-threading compression/decompression, you have to run fsarchiver with option -j X, where X is the number of compression threads you want. In general, it’s good to have as many compression jobs as there are processors/cores available, except if you want to leave enough power for other tasks. If you have a processor with multiple cores, you can combine the multi-threading compression with a very high compression level. That way you will have a very good compression ratio and it should not take too much time to compress. Keep in mind that you can use the multi-threading option at compression as well as decompression, even if it’s more interesting at compression which needs more power.
There are two options which you can use to choose the compression level you want to use. The legacy option is “-z” (lowercase) and it provides 10 compression levels with various speeds and ratios. These 10 levels correspond to five compression algorithms (lz4, lzo, gzip, bzip2, xz). The new option is “-Z” (uppercase) and it provides 22 compression levels which are all implemented by zstd. This algorithm provides better combinations of speed/ratio than other algorithms in most cases. Hence it is recommended to switch to this new compression option.
FSArchiver provides ten legacy compression levels. You can choose the compression level to use when you create an archive (by doing a savefs or savedir). You just have to use option -z X where X is the level to use. When you use a low number, the compression will be very quick and less efficient. The memory requirement for compressing and decompressing will be small. The higher the compression level is, the better the compression will be and the smaller the archive will be. But good compression levels will require a lot of time, and also the memory requirement can be very big.
FSArchiver 0.8.4 introduced support for zstd compression. This algorithm provides better combinations of speed/ratio than legacy algorithms in most cases. It is almost as fast as lz4 with level 1 and it its ratio is almost as good as xz with level 22. Compression methods in the medium of the range (gzip and bzip2) have become irrelevant as zstd can provide results which are both better and faster.
You can choose the compression level when you create an archive (by doing a savefs or savedir). You just have to use option -Z X where X is the level to use. When you use a low number, the compression will be very quick and less efficient. The memory requirement for compressing and decompressing will be small. The higher the compression level is, the better the compression will be and the smaller the archive will be.
xz and zstd provide the best compression ratios, hence a smaller archive file. The xz decompression is faster than bzip2, and the zstd decompression is even faster than xz for similar ratios. Hence it is recommended to use zstd with a high compression level if you want to minimize the size of archive files. The ratio and compression speed is similar to xz, and the zstd decompression will be much faster than xz. The bzip2 algorithm has become irrelevant as both xz and zstd provide better combinations of ratio/speed for high compression levels.
You must be aware that high xz and zstd compression levels require a lot of memory especially at compression time. These compression levels are recommended on recent computers having multiple cpu cores and large amounts of memory. If the compression fails because lack of memory, the uncompressed version of the data will be written to the archive and an error message will be printed in the terminal (the archive will still be valid as long as fsarchiver continues to run). In that case, using a lower compression level is recommended since it’s likely to work.
If you use multi-threading, there will be several compression-threads running in the same time, each one using some memory. Multi-threading compression will be faster on multi-core processors or systems with more than one cpu in general, but the compression ratio is the same.
In our tests, the same fsarchiver savefs command with two threads and compression level -z9 is using 1438 MiB of memory instead of 754 MiB when it has only one compression thread. This is because each compression thread requires a large amount of memory when the highest compression level is used (-z9). Usually memory will not be an issue with any recent desktop or server machine if you use compression levels inferior to -z9.
The biggest part of the memory requirement is the compression threads. The more compression threads you have, the more memory you need. Very high compression levels (especially -z9) requires a huge amount of memory. If you don’t have enough memory, use -z8 rather than -z9 or disable multi-threading.