0

Is it possible to change the number of threads for the xz command in the filesystem backup module? I would like to use all of the available cpu's on my system. I have tried to add --threads=0 in the Extra command-line parameters but it does not work giving error.

The error is:

tar: unrecognized option '--threads=0' Try 'tar --help' or 'tar --usage' for more information.

So it seems the options are passed to tar and not xz.

Fabrizio Mazzoni
  • 671
  • 1
  • 9
  • 24

2 Answers2

3

Use the XZ_DEFAULTS environment variable. For example, put this in your system-wide /etc/profile:

export XZ_DEFAULTS='--threads=0'
Geremia
  • 141
  • 6
1

Parallel compression will not get to the theoretical maximum throughput for a number of reasons. Most obvious of which, only recently has the man page admitted that xz --threads has been implemented.


With only options to GNU tar, you can provide your own compression wrapper: --use-compress-program=/usr/local/bin/xz-thread.sh

Where xz-thread.sh is a thin wrapper script that passes all the arguments it gets and adds some more:

#!/bin/sh
xz --threads=0 "$@"

In a similar way, you can substitute xz with other compress programs with gzip-like syntax, like zstd.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34
  • Thanks. Although now it is throwing error `tar: Cannot use multi-volume compressed archives.` I have disabled the webmin compression and added this as an extra command line parameter – Fabrizio Mazzoni Dec 10 '18 at 21:03
  • I was actually thinking of using pigz as a replacement for gzip which uses parallel compression. – Fabrizio Mazzoni Dec 10 '18 at 21:05
  • Good thing you tested. You may need to write your own backup and compress script beyond options to tar to accomplish what you want. – John Mahowald Dec 12 '18 at 01:01