environment.rst.inc 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. If a command needs an archive
  7. parameter, you can abbreviate as ``::archive``. If a command needs a repository parameter, you
  8. can either leave it away or abbreviate as ``::``, if a positional parameter is required.
  9. BORG_PASSPHRASE
  10. When set, use the value to answer the passphrase question for encrypted repositories.
  11. It is used when a passphrase is needed to access an encrypted repo as well as when a new
  12. passphrase should be initially set when initializing an encrypted repo.
  13. See also BORG_NEW_PASSPHRASE.
  14. BORG_PASSCOMMAND
  15. When set, use the standard output of the command (trailing newlines are stripped) to answer the
  16. passphrase question for encrypted repositories.
  17. It is used when a passphrase is needed to access an encrypted repo as well as when a new
  18. passphrase should be initially set when initializing an encrypted repo. Note that the command
  19. is executed without a shell. So variables, like ``$HOME`` will work, but ``~`` won't.
  20. If BORG_PASSPHRASE is also set, it takes precedence.
  21. See also BORG_NEW_PASSPHRASE.
  22. BORG_PASSPHRASE_FD
  23. When set, specifies a file descriptor to read a passphrase
  24. from. Programs starting borg may choose to open an anonymous pipe
  25. and use it to pass a passphrase. This is safer than passing via
  26. BORG_PASSPHRASE, because on some systems (e.g. Linux) environment
  27. can be examined by other processes.
  28. If BORG_PASSPHRASE or BORG_PASSCOMMAND are also set, they take precedence.
  29. BORG_NEW_PASSPHRASE
  30. When set, use the value to answer the passphrase question when a **new** passphrase is asked for.
  31. This variable is checked first. If it is not set, BORG_PASSPHRASE and BORG_PASSCOMMAND will also
  32. be checked.
  33. Main usecase for this is to fully automate ``borg change-passphrase``.
  34. BORG_DISPLAY_PASSPHRASE
  35. When set, use the value to answer the "display the passphrase for verification" question when defining a new passphrase for encrypted repositories.
  36. BORG_HOSTNAME_IS_UNIQUE=no
  37. Borg assumes that it can derive a unique hostname / identity (see ``borg debug info``).
  38. If this is not the case or you do not want Borg to automatically remove stale locks,
  39. set this to *no*.
  40. BORG_HOST_ID
  41. Borg usually computes a host id from the FQDN plus the results of ``uuid.getnode()`` (which usually returns
  42. a unique id based on the MAC address of the network interface. Except if that MAC happens to be all-zero - in
  43. that case it returns a random value, which is not what we want (because it kills automatic stale lock removal).
  44. So, if you have a all-zero MAC address or other reasons to better externally control the host id, just set this
  45. environment variable to a unique value. If all your FQDNs are unique, you can just use the FQDN. If not,
  46. use fqdn@uniqueid.
  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_TTL
  58. When set to a numeric value, this determines the maximum "time to live" for the files cache
  59. entries (default: 20). The files cache is used to quickly determine whether a file is unchanged.
  60. The FAQ explains this more detailed in: :ref:`always_chunking`
  61. BORG_SHOW_SYSINFO
  62. When set to no (default: yes), system information (like OS, Python version, ...) in
  63. exceptions is not shown.
  64. Please only use for good reasons as it makes issues harder to analyze.
  65. BORG_WORKAROUNDS
  66. A list of comma separated strings that trigger workarounds in borg,
  67. e.g. to work around bugs in other software.
  68. Currently known strings are:
  69. basesyncfile
  70. Use the more simple BaseSyncFile code to avoid issues with sync_file_range.
  71. You might need this to run borg on WSL (Windows Subsystem for Linux) or
  72. in systemd.nspawn containers on some architectures (e.g. ARM).
  73. Using this does not affect data safety, but might result in a more bursty
  74. write to disk behaviour (not continuously streaming to disk).
  75. Some automatic "answerers" (if set, they automatically answer confirmation questions):
  76. BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no (or =yes)
  77. For "Warning: Attempting to access a previously unknown unencrypted repository"
  78. BORG_RELOCATED_REPO_ACCESS_IS_OK=no (or =yes)
  79. For "Warning: The repository at location ... was previously located at ..."
  80. BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  81. For "Warning: 'check --repair' is an experimental feature that might result in data loss."
  82. BORG_DELETE_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  83. For "You requested to completely DELETE the repository *including* all archives it contains:"
  84. BORG_RECREATE_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  85. For "recreate is an experimental feature."
  86. Note: answers are case sensitive. setting an invalid answer value might either give the default
  87. answer or ask you interactively, depending on whether retries are allowed (they by default are
  88. allowed). So please test your scripts interactively before making them a non-interactive script.
  89. Directories and files:
  90. BORG_BASE_DIR
  91. Defaults to '$HOME', '~$USER', '~' (in that order)'.
  92. If we refer to ~ below, we in fact mean BORG_BASE_DIR.
  93. BORG_CACHE_DIR
  94. Defaults to '~/.cache/borg'. This directory contains the local cache and might need a lot
  95. of space for dealing with big repositories. Make sure you're aware of the associated
  96. security aspects of the cache location: :ref:`cache_security`
  97. BORG_CONFIG_DIR
  98. Defaults to '~/.config/borg'. This directory contains the whole config directories. See FAQ
  99. for security advisory about the data in this directory: :ref:`home_config_borg`
  100. BORG_SECURITY_DIR
  101. Defaults to '~/.config/borg/security'. This directory contains information borg uses to
  102. track its usage of NONCES ("numbers used once" - usually in encryption context) and other
  103. security relevant data. Will move with BORG_CONFIG_DIR variable unless specified.
  104. BORG_KEYS_DIR
  105. Defaults to '~/.config/borg/keys'. This directory contains keys for encrypted repositories.
  106. BORG_KEY_FILE
  107. When set, use the given filename as repository key file.
  108. TMPDIR
  109. This is where temporary files are stored (might need a lot of temporary space for some
  110. operations), see tempfile_ for details.
  111. Building:
  112. BORG_OPENSSL_PREFIX
  113. Adds given OpenSSL header file directory to the default locations (setup.py).
  114. BORG_LIBLZ4_PREFIX
  115. Adds given prefix directory to the default locations. If a 'include/lz4.h' is found Borg
  116. will be linked against the system liblz4 instead of a bundled implementation. (setup.py)
  117. BORG_LIBB2_PREFIX
  118. Adds given prefix directory to the default locations. If a 'include/blake2.h' is found Borg
  119. will be linked against the system libb2 instead of a bundled implementation. (setup.py)
  120. BORG_LIBZSTD_PREFIX
  121. Adds given prefix directory to the default locations. If a 'include/zstd.h' is found Borg
  122. will be linked against the system libzstd instead of a bundled implementation. (setup.py)
  123. Please note:
  124. - be very careful when using the "yes" sayers, the warnings with prompt exist for your / your data's security/safety
  125. - also be very careful when putting your passphrase into a script, make sure it has appropriate file permissions
  126. (e.g. mode 600, root:root).
  127. .. _INI: https://docs.python.org/3/library/logging.config.html#configuration-file-format
  128. .. _tempfile: https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir