environment.rst.inc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. Environment Variables
  2. ~~~~~~~~~~~~~~~~~~~~~
  3. Borg uses some environment variables for automation:
  4. General:
  5. BORG_REPO
  6. When set, use the value to give the default repository location.
  7. Use this so you do not need to type ``--repo /path/to/my/repo`` all the time.
  8. BORG_OTHER_REPO
  9. Similar to BORG_REPO, but gives the default for ``--other-repo``.
  10. BORG_PASSPHRASE
  11. When set, use the value to answer the passphrase question for encrypted repositories.
  12. It is used when a passphrase is needed to access an encrypted repo as well as when a new
  13. passphrase should be initially set when initializing an encrypted repo.
  14. See also BORG_NEW_PASSPHRASE.
  15. BORG_PASSCOMMAND
  16. When set, use the standard output of the command (trailing newlines are stripped) to answer the
  17. passphrase question for encrypted repositories.
  18. It is used when a passphrase is needed to access an encrypted repo as well as when a new
  19. passphrase should be initially set when initializing an encrypted repo. Note that the command
  20. is executed without a shell. So variables, like ``$HOME`` will work, but ``~`` won't.
  21. If BORG_PASSPHRASE is also set, it takes precedence.
  22. See also BORG_NEW_PASSPHRASE.
  23. BORG_PASSPHRASE_FD
  24. When set, specifies a file descriptor to read a passphrase
  25. from. Programs starting borg may choose to open an anonymous pipe
  26. and use it to pass a passphrase. This is safer than passing via
  27. BORG_PASSPHRASE, because on some systems (e.g. Linux) environment
  28. can be examined by other processes.
  29. If BORG_PASSPHRASE or BORG_PASSCOMMAND are also set, they take precedence.
  30. BORG_NEW_PASSPHRASE
  31. When set, use the value to answer the passphrase question when a **new** passphrase is asked for.
  32. This variable is checked first. If it is not set, BORG_PASSPHRASE and BORG_PASSCOMMAND will also
  33. be checked.
  34. Main usecase for this is to automate fully ``borg change-passphrase``.
  35. BORG_DISPLAY_PASSPHRASE
  36. When set, use the value to answer the "display the passphrase for verification" question when defining a new passphrase for encrypted repositories.
  37. BORG_HOST_ID
  38. Borg usually computes a host id from the FQDN plus the results of ``uuid.getnode()`` (which usually returns
  39. a unique id based on the MAC address of the network interface. Except if that MAC happens to be all-zero - in
  40. that case it returns a random value, which is not what we want (because it kills automatic stale lock removal).
  41. So, if you have a all-zero MAC address or other reasons to control better externally the host id, just set this
  42. environment variable to a unique value. If all your FQDNs are unique, you can just use the FQDN. If not,
  43. use fqdn@uniqueid.
  44. BORG_LOCK_WAIT
  45. You can set the default value for the ``--lock-wait`` option with this, so
  46. you do not need to give it as a commandline option.
  47. BORG_LOGGING_CONF
  48. When set, use the given filename as INI_-style logging configuration.
  49. A basic example conf can be found at ``docs/misc/logging.conf``.
  50. BORG_RSH
  51. When set, use this command instead of ``ssh``. This can be used to specify ssh options, such as
  52. a custom identity file ``ssh -i /path/to/private/key``. See ``man ssh`` for other options. Using
  53. the ``--rsh CMD`` commandline option overrides the environment variable.
  54. BORG_REMOTE_PATH
  55. When set, use the given path as borg executable on the remote (defaults to "borg" if unset).
  56. Using ``--remote-path PATH`` commandline option overrides the environment variable.
  57. BORG_FILES_CACHE_SUFFIX
  58. When set to a value at least one character long, instructs borg to use a specifically named
  59. (based on the suffix) alternative files cache. This can be used to avoid loading and saving
  60. cache entries for backup sources other than the current sources.
  61. BORG_FILES_CACHE_TTL
  62. When set to a numeric value, this determines the maximum "time to live" for the files cache
  63. entries (default: 20). The files cache is used to determine quickly whether a file is unchanged.
  64. The FAQ explains this more detailed in: :ref:`always_chunking`
  65. BORG_SHOW_SYSINFO
  66. When set to no (default: yes), system information (like OS, Python version, ...) in
  67. exceptions is not shown.
  68. Please only use for good reasons as it makes issues harder to analyze.
  69. BORG_FUSE_IMPL
  70. Choose the lowlevel FUSE implementation borg shall use for ``borg mount``.
  71. This is a comma-separated list of implementation names, they are tried in the
  72. given order, e.g.:
  73. - ``pyfuse3,llfuse``: default, first try to load pyfuse3, then try to load llfuse.
  74. - ``llfuse,pyfuse3``: first try to load llfuse, then try to load pyfuse3.
  75. - ``pyfuse3``: only try to load pyfuse3
  76. - ``llfuse``: only try to load llfuse
  77. - ``none``: do not try to load an implementation
  78. BORG_SELFTEST
  79. This can be used to influence borg's builtin self-tests. The default is to execute the tests
  80. at the beginning of each borg command invocation.
  81. BORG_SELFTEST=disabled can be used to switch off the tests and rather save some time.
  82. Disabling is not recommended for normal borg users, but large scale borg storage providers can
  83. use this to optimize production servers after at least doing a one-time test borg (with
  84. selftests not disabled) when installing or upgrading machines / OS / borg.
  85. BORG_WORKAROUNDS
  86. A list of comma separated strings that trigger workarounds in borg,
  87. e.g. to work around bugs in other software.
  88. Currently known strings are:
  89. basesyncfile
  90. Use the more simple BaseSyncFile code to avoid issues with sync_file_range.
  91. You might need this to run borg on WSL (Windows Subsystem for Linux) or
  92. in systemd.nspawn containers on some architectures (e.g. ARM).
  93. Using this does not affect data safety, but might result in a more bursty
  94. write to disk behaviour (not continuously streaming to disk).
  95. retry_erofs
  96. Retry opening a file without O_NOATIME if opening a file with O_NOATIME
  97. caused EROFS. You will need this to make archives from volume shadow copies
  98. in WSL1 (Windows Subsystem for Linux 1).
  99. Some automatic "answerers" (if set, they automatically answer confirmation questions):
  100. BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no (or =yes)
  101. For "Warning: Attempting to access a previously unknown unencrypted repository"
  102. BORG_RELOCATED_REPO_ACCESS_IS_OK=no (or =yes)
  103. For "Warning: The repository at location ... was previously located at ..."
  104. BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  105. For "This is a potentially dangerous function..." (check --repair)
  106. BORG_DELETE_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  107. For "You requested to DELETE the repository completely *including* all archives it contains:"
  108. Note: answers are case sensitive. setting an invalid answer value might either give the default
  109. answer or ask you interactively, depending on whether retries are allowed (they by default are
  110. allowed). So please test your scripts interactively before making them a non-interactive script.
  111. .. _XDG env var: https://specifications.freedesktop.org/basedir-spec/0.6/ar01s03.html
  112. Directories and files:
  113. BORG_BASE_DIR
  114. Defaults to ``$HOME`` or ``~$USER`` or ``~`` (in that order).
  115. If you want to move all borg-specific folders to a custom path at once, all you need to do is
  116. to modify ``BORG_BASE_DIR``: the other paths for cache, config etc. will adapt accordingly
  117. (assuming you didn't set them to a different custom value).
  118. BORG_CACHE_DIR
  119. Defaults to ``$BORG_BASE_DIR/.cache/borg``. If ``BORG_BASE_DIR`` is not explicitly set while
  120. `XDG env var`_ ``XDG_CACHE_HOME`` is set, then ``$XDG_CACHE_HOME/borg`` is being used instead.
  121. This directory contains the local cache and might need a lot
  122. of space for dealing with big repositories. Make sure you're aware of the associated
  123. security aspects of the cache location: :ref:`cache_security`
  124. BORG_CONFIG_DIR
  125. Defaults to ``$BORG_BASE_DIR/.config/borg``. If ``BORG_BASE_DIR`` is not explicitly set while
  126. `XDG env var`_ ``XDG_CONFIG_HOME`` is set, then ``$XDG_CONFIG_HOME/borg`` is being used instead.
  127. This directory contains all borg configuration directories, see the FAQ
  128. for a security advisory about the data in this directory: :ref:`home_config_borg`
  129. BORG_SECURITY_DIR
  130. Defaults to ``$BORG_CONFIG_DIR/security``.
  131. This directory contains information borg uses to track its usage of NONCES ("numbers used
  132. once" - usually in encryption context) and other security relevant data.
  133. BORG_KEYS_DIR
  134. Defaults to ``$BORG_CONFIG_DIR/keys``.
  135. This directory contains keys for encrypted repositories.
  136. BORG_KEY_FILE
  137. When set, use the given filename as repository key file.
  138. TMPDIR
  139. This is where temporary files are stored (might need a lot of temporary space for some
  140. operations), see tempfile_ for details.
  141. Building:
  142. BORG_OPENSSL_PREFIX
  143. Adds given OpenSSL header file directory to the default locations (setup.py).
  144. BORG_LIBLZ4_PREFIX
  145. Adds given prefix directory to the default locations. If a 'include/lz4.h' is found Borg
  146. will be linked against the system liblz4 instead of a bundled implementation. (setup.py)
  147. BORG_LIBB2_PREFIX
  148. Adds given prefix directory to the default locations. If a 'include/blake2.h' is found Borg
  149. will be linked against the system libb2 instead of a bundled implementation. (setup.py)
  150. BORG_LIBZSTD_PREFIX
  151. Adds given prefix directory to the default locations. If a 'include/zstd.h' is found Borg
  152. will be linked against the system libzstd instead of a bundled implementation. (setup.py)
  153. Please note:
  154. - Be very careful when using the "yes" sayers, the warnings with prompt exist for your / your data's security/safety.
  155. - Also be very careful when putting your passphrase into a script, make sure it has appropriate file permissions (e.g.
  156. mode 600, root:root).
  157. .. _INI: https://docs.python.org/3/library/logging.config.html#configuration-file-format
  158. .. _tempfile: https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir