environment.rst.inc 14 KB

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