environment.rst.inc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 (and BORG_OTHER_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 (and BORG_OTHER_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 (and BORG_OTHER_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_DEBUG_PASSPHRASE
  38. When set to YES, display debugging information that includes passphrases used and passphrase related env vars set.
  39. BORG_EXIT_CODES
  40. When set to "modern", the borg process will return more specific exit codes (rc).
  41. When set to "legacy", the borg process will return rc 2 for all errors, 1 for all warnings, 0 for success.
  42. Default is "modern".
  43. BORG_HOST_ID
  44. Borg usually computes a host id from the FQDN plus the results of ``uuid.getnode()`` (which usually returns
  45. a unique id based on the MAC address of the network interface. Except if that MAC happens to be all-zero - in
  46. that case it returns a random value, which is not what we want (because it kills automatic stale lock removal).
  47. So, if you have a all-zero MAC address or other reasons to control better externally the host id, just set this
  48. environment variable to a unique value. If all your FQDNs are unique, you can just use the FQDN. If not,
  49. use fqdn@uniqueid.
  50. BORG_LOCK_WAIT
  51. You can set the default value for the ``--lock-wait`` option with this, so
  52. you do not need to give it as a commandline option.
  53. BORG_LOGGING_CONF
  54. When set, use the given filename as INI_-style logging configuration.
  55. A basic example conf can be found at ``docs/misc/logging.conf``.
  56. BORG_RSH
  57. When set, use this command instead of ``ssh``. This can be used to specify ssh options, such as
  58. a custom identity file ``ssh -i /path/to/private/key``. See ``man ssh`` for other options. Using
  59. the ``--rsh CMD`` commandline option overrides the environment variable.
  60. BORG_REMOTE_PATH
  61. When set, use the given path as borg executable on the remote (defaults to "borg" if unset).
  62. Using ``--remote-path PATH`` commandline option overrides the environment variable.
  63. BORG_FILES_CACHE_SUFFIX
  64. When set to a value at least one character long, instructs borg to use a specifically named
  65. (based on the suffix) alternative files cache. This can be used to avoid loading and saving
  66. cache entries for backup sources other than the current sources.
  67. BORG_FILES_CACHE_TTL
  68. When set to a numeric value, this determines the maximum "time to live" for the files cache
  69. entries (default: 2). The files cache is used to determine quickly whether a file is unchanged.
  70. BORG_USE_CHUNKS_ARCHIVE
  71. When set to no (default: yes), the ``chunks.archive.d`` folder will not be used. This reduces
  72. disk space usage but slows down cache resyncs.
  73. BORG_SHOW_SYSINFO
  74. When set to no (default: yes), system information (like OS, Python version, ...) in
  75. exceptions is not shown.
  76. Please only use for good reasons as it makes issues harder to analyze.
  77. BORG_FUSE_IMPL
  78. Choose the lowlevel FUSE implementation borg shall use for ``borg mount``.
  79. This is a comma-separated list of implementation names, they are tried in the
  80. given order, e.g.:
  81. - ``pyfuse3,llfuse``: default, first try to load pyfuse3, then try to load llfuse.
  82. - ``llfuse,pyfuse3``: first try to load llfuse, then try to load pyfuse3.
  83. - ``pyfuse3``: only try to load pyfuse3
  84. - ``llfuse``: only try to load llfuse
  85. - ``none``: do not try to load an implementation
  86. BORG_SELFTEST
  87. This can be used to influence borg's builtin self-tests. The default is to execute the tests
  88. at the beginning of each borg command invocation.
  89. BORG_SELFTEST=disabled can be used to switch off the tests and rather save some time.
  90. Disabling is not recommended for normal borg users, but large scale borg storage providers can
  91. use this to optimize production servers after at least doing a one-time test borg (with
  92. selftests not disabled) when installing or upgrading machines / OS / borg.
  93. BORG_WORKAROUNDS
  94. A list of comma separated strings that trigger workarounds in borg,
  95. e.g. to work around bugs in other software.
  96. Currently known strings are:
  97. basesyncfile
  98. Use the more simple BaseSyncFile code to avoid issues with sync_file_range.
  99. You might need this to run borg on WSL (Windows Subsystem for Linux) or
  100. in systemd.nspawn containers on some architectures (e.g. ARM).
  101. Using this does not affect data safety, but might result in a more bursty
  102. write to disk behaviour (not continuously streaming to disk).
  103. retry_erofs
  104. Retry opening a file without O_NOATIME if opening a file with O_NOATIME
  105. caused EROFS. You will need this to make archives from volume shadow copies
  106. in WSL1 (Windows Subsystem for Linux 1).
  107. authenticated_no_key
  108. Work around a lost passphrase or key for an ``authenticated`` mode repository
  109. (these are only authenticated, but not encrypted).
  110. If the key is missing in the repository config, add ``key = anything`` there.
  111. This workaround is **only** for emergencies and **only** to extract data
  112. from an affected repository (read-only access)::
  113. BORG_WORKAROUNDS=authenticated_no_key borg extract --repo repo archive
  114. After you have extracted all data you need, you MUST delete the repository::
  115. BORG_WORKAROUNDS=authenticated_no_key borg delete repo
  116. Now you can init a fresh repo. Make sure you do not use the workaround any more.
  117. Output formatting:
  118. BORG_LIST_FORMAT
  119. Giving the default value for ``borg repo-list --format=X``.
  120. BORG_RLIST_FORMAT
  121. Giving the default value for ``borg repo-list --format=X``.
  122. BORG_PRUNE_FORMAT
  123. Giving the default value for ``borg prune --format=X``.
  124. Some automatic "answerers" (if set, they automatically answer confirmation questions):
  125. BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no (or =yes)
  126. For "Warning: Attempting to access a previously unknown unencrypted repository"
  127. BORG_RELOCATED_REPO_ACCESS_IS_OK=no (or =yes)
  128. For "Warning: The repository at location ... was previously located at ..."
  129. BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  130. For "This is a potentially dangerous function..." (check --repair)
  131. BORG_DELETE_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  132. For "You requested to DELETE the repository completely *including* all archives it contains:"
  133. Note: answers are case sensitive. setting an invalid answer value might either give the default
  134. answer or ask you interactively, depending on whether retries are allowed (they by default are
  135. allowed). So please test your scripts interactively before making them a non-interactive script.
  136. .. _XDG env var: https://specifications.freedesktop.org/basedir-spec/0.6/ar01s03.html
  137. Directories and files:
  138. BORG_BASE_DIR
  139. Defaults to ``$HOME`` or ``~$USER`` or ``~`` (in that order).
  140. If you want to move all borg-specific folders to a custom path at once, all you need to do is
  141. to modify ``BORG_BASE_DIR``: the other paths for cache, config etc. will adapt accordingly
  142. (assuming you didn't set them to a different custom value).
  143. BORG_CACHE_DIR
  144. Defaults to ``$BORG_BASE_DIR/.cache/borg``. If ``BORG_BASE_DIR`` is not explicitly set while
  145. `XDG env var`_ ``XDG_CACHE_HOME`` is set, then ``$XDG_CACHE_HOME/borg`` is being used instead.
  146. This directory contains the local cache and might need a lot
  147. of space for dealing with big repositories. Make sure you're aware of the associated
  148. security aspects of the cache location: :ref:`cache_security`
  149. BORG_CONFIG_DIR
  150. Defaults to ``$BORG_BASE_DIR/.config/borg``. If ``BORG_BASE_DIR`` is not explicitly set while
  151. `XDG env var`_ ``XDG_CONFIG_HOME`` is set, then ``$XDG_CONFIG_HOME/borg`` is being used instead.
  152. This directory contains all borg configuration directories, see the FAQ
  153. for a security advisory about the data in this directory: :ref:`home_config_borg`
  154. BORG_DATA_DIR
  155. Defaults to ``$BORG_BASE_DIR/.local/share/borg``. If ``BORG_BASE_DIR`` is not explicitly set while
  156. `XDG env var`_ ``XDG_DATA_HOME`` is set, then ``$XDG_DATA_HOME/borg`` is being used instead.
  157. This directory contains all borg data directories, see the FAQ
  158. for a security advisory about the data in this directory: :ref:`home_data_borg`
  159. BORG_RUNTIME_DIR
  160. Defaults to ``$BORG_BASE_DIR/.cache/borg``. If ``BORG_BASE_DIR`` is not explicitly set while
  161. `XDG env var`_ ``XDG_RUNTIME_DIR`` is set, then ``$XDG_RUNTIME_DIR/borg`` is being used instead.
  162. This directory contains borg runtime files, like e.g. the socket file.
  163. BORG_SECURITY_DIR
  164. Defaults to ``$BORG_DATA_DIR/security``.
  165. This directory contains security relevant data.
  166. BORG_KEYS_DIR
  167. Defaults to ``$BORG_CONFIG_DIR/keys``.
  168. This directory contains keys for encrypted repositories.
  169. BORG_KEY_FILE
  170. When set, use the given path as repository key file. Please note that this is only
  171. for rather special applications that externally fully manage the key files:
  172. - this setting only applies to the keyfile modes (not to the repokey modes).
  173. - using a full, absolute path to the key file is recommended.
  174. - all directories in the given path must exist.
  175. - this setting forces borg to use the key file at the given location.
  176. - the key file must either exist (for most commands) or will be created (``borg repo-create``).
  177. - you need to give a different path for different repositories.
  178. - you need to point to the correct key file matching the repository the command will operate on.
  179. TMPDIR
  180. This is where temporary files are stored (might need a lot of temporary space for some
  181. operations), see tempfile_ for details.
  182. Building:
  183. BORG_OPENSSL_NAME
  184. Defines the subdirectory name for OpenSSL (setup.py).
  185. BORG_OPENSSL_PREFIX
  186. Adds given OpenSSL header file directory to the default locations (setup.py).
  187. BORG_LIBACL_PREFIX
  188. Adds given prefix directory to the default locations. If an 'include/acl/libacl.h' is found
  189. Borg will be linked against the system libacl instead of a bundled implementation. (setup.py)
  190. BORG_LIBLZ4_PREFIX
  191. Adds given prefix directory to the default locations. If a 'include/lz4.h' is found Borg
  192. will be linked against the system liblz4 instead of a bundled implementation. (setup.py)
  193. BORG_LIBZSTD_PREFIX
  194. Adds given prefix directory to the default locations. If a 'include/zstd.h' is found Borg
  195. will be linked against the system libzstd instead of a bundled implementation. (setup.py)
  196. Please note:
  197. - Be very careful when using the "yes" sayers, the warnings with prompt exist for your / your data's security/safety.
  198. - Also be very careful when putting your passphrase into a script, make sure it has appropriate file permissions (e.g.
  199. mode 600, root:root).
  200. .. _INI: https://docs.python.org/3/library/logging.config.html#configuration-file-format
  201. .. _tempfile: https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir