Add environment variable RESTIC_COMPRESSION

This commit is contained in:
Michael Eischer 2022-07-30 16:21:53 +02:00
parent 4ffd479ba4
commit 5723c72eb1
4 changed files with 10 additions and 1 deletions

View file

@ -8,6 +8,7 @@ You can configure if data is compressed with the option `--compression`. It can
be set to `auto` (the default, which will compress very fast), `max` (which
will trade backup speed and CPU usage for better compression), or `off` (which
disables compression). Each setting is only applied for the single run of restic.
The option can also be set via the environment variable `RESTIC_COMPRESSION`.
The new format version has not received much testing yet. Do not rely on it as
your only backup copy! Please run `check` in regular intervals to detect any

View file

@ -125,6 +125,12 @@ func init() {
// Use our "generate" command instead of the cobra provided "completion" command
cmdRoot.CompletionOptions.DisableDefaultCmd = true
comp := os.Getenv("RESTIC_COMPRESSION")
if comp != "" {
// ignore error as there's no good way to handle it
_ = globalOptions.Compression.Set(comp)
}
restoreTerminal()
}

View file

@ -552,6 +552,7 @@ environment variables. The following lists these environment variables:
RESTIC_PASSWORD_COMMAND Command printing the password for the repository to stdout
RESTIC_KEY_HINT ID of key to try decrypting first, before other keys
RESTIC_CACHE_DIR Location of the cache directory
RESTIC_COMPRESSION Compression mode (only available for repository format version 2)
RESTIC_PROGRESS_FPS Frames per second by which the progress bar is updated
TMPDIR Location for temporary files

View file

@ -46,4 +46,5 @@ For a repository using at least repository format version 2, you can configure h
is compressed with the option ``--compression``. It can be set to ```auto``` (the default,
which will compress very fast), ``max`` (which will trade backup speed and CPU usage for
slightly better compression), or ``off`` (which disables compression). Each setting is
only applied for the single run of restic.
only applied for the single run of restic. The option can also be set via the environment
variable ``RESTIC_COMPRESSION``.