usage_general.rst.inc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. Repository URLs
  2. ~~~~~~~~~~~~~~~
  3. **Local filesystem** (or locally mounted network filesystem):
  4. ``/path/to/repo`` - filesystem path to repo directory, absolute path
  5. ``path/to/repo`` - filesystem path to repo directory, relative path
  6. Also, stuff like ``~/path/to/repo`` or ``~other/path/to/repo`` works (this is
  7. expanded by your shell).
  8. Note: you may also prepend a ``file://`` to a filesystem path to get URL style.
  9. **Remote repositories** accessed via ssh user@host:
  10. ``user@host:/path/to/repo`` - remote repo, absolute path
  11. ``ssh://user@host:port/path/to/repo`` - same, alternative syntax, port can be given
  12. **Remote repositories with relative paths** can be given using this syntax:
  13. ``user@host:path/to/repo`` - path relative to current directory
  14. ``user@host:~/path/to/repo`` - path relative to user's home directory
  15. ``user@host:~other/path/to/repo`` - path relative to other's home directory
  16. Note: giving ``user@host:/./path/to/repo`` or ``user@host:/~/path/to/repo`` or
  17. ``user@host:/~other/path/to/repo`` is also supported, but not required here.
  18. **Remote repositories with relative paths, alternative syntax with port**:
  19. ``ssh://user@host:port/./path/to/repo`` - path relative to current directory
  20. ``ssh://user@host:port/~/path/to/repo`` - path relative to user's home directory
  21. ``ssh://user@host:port/~other/path/to/repo`` - path relative to other's home directory
  22. If you frequently need the same repo URL, it is a good idea to set the
  23. ``BORG_REPO`` environment variable to set a default for the repo URL:
  24. ::
  25. export BORG_REPO='ssh://user@host:port/path/to/repo'
  26. Then just leave away the repo URL if only a repo URL is needed and you want
  27. to use the default - it will be read from BORG_REPO then.
  28. Use ``::`` syntax to give the repo URL when syntax requires giving a positional
  29. argument for the repo (e.g. ``borg mount :: /mnt``).
  30. Repository / Archive Locations
  31. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  32. Many commands want either a repository (just give the repo URL, see above) or
  33. an archive location, which is a repo URL followed by ``::archive_name``.
  34. Archive names must not contain the ``/`` (slash) character. For simplicity,
  35. maybe also avoid blanks or other characters that have special meaning on the
  36. shell or in a filesystem (borg mount will use the archive name as directory
  37. name).
  38. If you have set BORG_REPO (see above) and an archive location is needed, use
  39. ``::archive_name`` - the repo URL part is then read from BORG_REPO.
  40. Type of log output
  41. ~~~~~~~~~~~~~~~~~~
  42. The log level of the builtin logging configuration defaults to WARNING.
  43. This is because we want Borg to be mostly silent and only output
  44. warnings, errors and critical messages, unless output has been requested
  45. by supplying an option that implies output (e.g. ``--list`` or ``--progress``).
  46. Log levels: DEBUG < INFO < WARNING < ERROR < CRITICAL
  47. Use ``--debug`` to set DEBUG log level -
  48. to get debug, info, warning, error and critical level output.
  49. Use ``--info`` (or ``-v`` or ``--verbose``) to set INFO log level -
  50. to get info, warning, error and critical level output.
  51. Use ``--warning`` (default) to set WARNING log level -
  52. to get warning, error and critical level output.
  53. Use ``--error`` to set ERROR log level -
  54. to get error and critical level output.
  55. Use ``--critical`` to set CRITICAL log level -
  56. to get critical level output.
  57. While you can set misc. log levels, do not expect that every command will
  58. give different output on different log levels - it's just a possibility.
  59. .. warning:: Options ``--critical`` and ``--error`` are provided for completeness,
  60. their usage is not recommended as you might miss important information.
  61. Return codes
  62. ~~~~~~~~~~~~
  63. Borg can exit with the following return codes (rc):
  64. =========== =======
  65. Return code Meaning
  66. =========== =======
  67. 0 success (logged as INFO)
  68. 1 warning (operation reached its normal end, but there were warnings --
  69. you should check the log, logged as WARNING)
  70. 2 error (like a fatal error, a local or remote exception, the operation
  71. did not reach its normal end, logged as ERROR)
  72. 128+N killed by signal N (e.g. 137 == kill -9)
  73. =========== =======
  74. If you use ``--show-rc``, the return code is also logged at the indicated
  75. level as the last log entry.
  76. .. _env_vars:
  77. Environment Variables
  78. ~~~~~~~~~~~~~~~~~~~~~
  79. Borg uses some environment variables for automation:
  80. General:
  81. BORG_REPO
  82. When set, use the value to give the default repository location. If a command needs an archive
  83. parameter, you can abbreviate as ``::archive``. If a command needs a repository parameter, you
  84. can either leave it away or abbreviate as ``::``, if a positional parameter is required.
  85. BORG_PASSPHRASE
  86. When set, use the value to answer the passphrase question for encrypted repositories.
  87. It is used when a passphrase is needed to access an encrypted repo as well as when a new
  88. passphrase should be initially set when initializing an encrypted repo.
  89. See also BORG_NEW_PASSPHRASE.
  90. BORG_PASSCOMMAND
  91. When set, use the standard output of the command (trailing newlines are stripped) to answer the
  92. passphrase question for encrypted repositories.
  93. It is used when a passphrase is needed to access an encrypted repo as well as when a new
  94. passphrase should be initially set when initializing an encrypted repo.
  95. If BORG_PASSPHRASE is also set, it takes precedence.
  96. See also BORG_NEW_PASSPHRASE.
  97. BORG_NEW_PASSPHRASE
  98. When set, use the value to answer the passphrase question when a **new** passphrase is asked for.
  99. This variable is checked first. If it is not set, BORG_PASSPHRASE and BORG_PASSCOMMAND will also
  100. be checked.
  101. Main usecase for this is to fully automate ``borg change-passphrase``.
  102. BORG_DISPLAY_PASSPHRASE
  103. When set, use the value to answer the "display the passphrase for verification" question when defining a new passphrase for encrypted repositories.
  104. BORG_HOSTNAME_IS_UNIQUE=no
  105. Borg assumes that it can derive a unique hostname / identity (see ``borg debug info``).
  106. If this is not the case or you do not want Borg to automatically remove stale locks,
  107. set this to *no*.
  108. BORG_LOGGING_CONF
  109. When set, use the given filename as INI_-style logging configuration.
  110. BORG_RSH
  111. When set, use this command instead of ``ssh``. This can be used to specify ssh options, such as
  112. a custom identity file ``ssh -i /path/to/private/key``. See ``man ssh`` for other options.
  113. BORG_REMOTE_PATH
  114. When set, use the given path as borg executable on the remote (defaults to "borg" if unset).
  115. Using ``--remote-path PATH`` commandline option overrides the environment variable.
  116. BORG_FILES_CACHE_TTL
  117. When set to a numeric value, this determines the maximum "time to live" for the files cache
  118. entries (default: 20). The files cache is used to quickly determine whether a file is unchanged.
  119. The FAQ explains this more detailed in: :ref:`always_chunking`
  120. TMPDIR
  121. where temporary files are stored (might need a lot of temporary space for some operations)
  122. Some automatic "answerers" (if set, they automatically answer confirmation questions):
  123. BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no (or =yes)
  124. For "Warning: Attempting to access a previously unknown unencrypted repository"
  125. BORG_RELOCATED_REPO_ACCESS_IS_OK=no (or =yes)
  126. For "Warning: The repository at location ... was previously located at ..."
  127. BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  128. For "Warning: 'check --repair' is an experimental feature that might result in data loss."
  129. BORG_DELETE_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  130. For "You requested to completely DELETE the repository *including* all archives it contains:"
  131. BORG_RECREATE_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  132. For "recreate is an experimental feature."
  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. Directories and files:
  137. BORG_KEYS_DIR
  138. Default to '~/.config/borg/keys'. This directory contains keys for encrypted repositories.
  139. BORG_KEY_FILE
  140. When set, use the given filename as repository key file.
  141. BORG_SECURITY_DIR
  142. Default to '~/.config/borg/security'. This directory contains information borg uses to
  143. track its usage of NONCES ("numbers used once" - usually in encryption context) and other
  144. security relevant data.
  145. BORG_CACHE_DIR
  146. Default to '~/.cache/borg'. This directory contains the local cache and might need a lot
  147. of space for dealing with big repositories).
  148. Building:
  149. BORG_OPENSSL_PREFIX
  150. Adds given OpenSSL header file directory to the default locations (setup.py).
  151. BORG_LZ4_PREFIX
  152. Adds given LZ4 header file directory to the default locations (setup.py).
  153. BORG_LIBB2_PREFIX
  154. Adds given prefix directory to the default locations. If a 'include/blake2.h' is found Borg
  155. will be linked against the system libb2 instead of a bundled implementation. (setup.py)
  156. Please note:
  157. - be very careful when using the "yes" sayers, the warnings with prompt exist for your / your data's security/safety
  158. - also be very careful when putting your passphrase into a script, make sure it has appropriate file permissions
  159. (e.g. mode 600, root:root).
  160. .. _INI: https://docs.python.org/3.4/library/logging.config.html#configuration-file-format
  161. .. _file-systems:
  162. File systems
  163. ~~~~~~~~~~~~
  164. We strongly recommend against using Borg (or any other database-like
  165. software) on non-journaling file systems like FAT, since it is not
  166. possible to assume any consistency in case of power failures (or a
  167. sudden disconnect of an external drive or similar failures).
  168. While Borg uses a data store that is resilient against these failures
  169. when used on journaling file systems, it is not possible to guarantee
  170. this with some hardware -- independent of the software used. We don't
  171. know a list of affected hardware.
  172. If you are suspicious whether your Borg repository is still consistent
  173. and readable after one of the failures mentioned above occurred, run
  174. ``borg check --verify-data`` to make sure it is consistent.
  175. Units
  176. ~~~~~
  177. To display quantities, Borg takes care of respecting the
  178. usual conventions of scale. Disk sizes are displayed in `decimal
  179. <https://en.wikipedia.org/wiki/Decimal>`_, using powers of ten (so
  180. ``kB`` means 1000 bytes). For memory usage, `binary prefixes
  181. <https://en.wikipedia.org/wiki/Binary_prefix>`_ are used, and are
  182. indicated using the `IEC binary prefixes
  183. <https://en.wikipedia.org/wiki/IEC_80000-13#Prefixes_for_binary_multiples>`_,
  184. using powers of two (so ``KiB`` means 1024 bytes).
  185. Date and Time
  186. ~~~~~~~~~~~~~
  187. We format date and time conforming to ISO-8601, that is: YYYY-MM-DD and
  188. HH:MM:SS (24h clock).
  189. For more information about that, see: https://xkcd.com/1179/
  190. Unless otherwise noted, we display local date and time.
  191. Internally, we store and process date and time as UTC.
  192. Resource Usage
  193. ~~~~~~~~~~~~~~
  194. Borg might use a lot of resources depending on the size of the data set it is dealing with.
  195. If one uses Borg in a client/server way (with a ssh: repository),
  196. the resource usage occurs in part on the client and in another part on the
  197. server.
  198. If one uses Borg as a single process (with a filesystem repo),
  199. all the resource usage occurs in that one process, so just add up client +
  200. server to get the approximate resource usage.
  201. CPU client:
  202. borg create: does chunking, hashing, compression, crypto (high CPU usage)
  203. chunks cache sync: quite heavy on CPU, doing lots of hashtable operations.
  204. borg extract: crypto, decompression (medium to high CPU usage)
  205. borg check: similar to extract, but depends on options given.
  206. borg prune / borg delete archive: low to medium CPU usage
  207. borg delete repo: done on the server
  208. It won't go beyond 100% of 1 core as the code is currently single-threaded.
  209. Especially higher zlib and lzma compression levels use significant amounts
  210. of CPU cycles. Crypto might be cheap on the CPU (if hardware accelerated) or
  211. expensive (if not).
  212. CPU server:
  213. It usually doesn't need much CPU, it just deals with the key/value store
  214. (repository) and uses the repository index for that.
  215. borg check: the repository check computes the checksums of all chunks
  216. (medium CPU usage)
  217. borg delete repo: low CPU usage
  218. CPU (only for client/server operation):
  219. When using borg in a client/server way with a ssh:-type repo, the ssh
  220. processes used for the transport layer will need some CPU on the client and
  221. on the server due to the crypto they are doing - esp. if you are pumping
  222. big amounts of data.
  223. Memory (RAM) client:
  224. The chunks index and the files index are read into memory for performance
  225. reasons. Might need big amounts of memory (see below).
  226. Compression, esp. lzma compression with high levels might need substantial
  227. amounts of memory.
  228. Memory (RAM) server:
  229. The server process will load the repository index into memory. Might need
  230. considerable amounts of memory, but less than on the client (see below).
  231. Chunks index (client only):
  232. Proportional to the amount of data chunks in your repo. Lots of chunks
  233. in your repo imply a big chunks index.
  234. It is possible to tweak the chunker params (see create options).
  235. Files index (client only):
  236. Proportional to the amount of files in your last backups. Can be switched
  237. off (see create options), but next backup might be much slower if you do.
  238. The speed benefit of using the files cache is proportional to file size.
  239. Repository index (server only):
  240. Proportional to the amount of data chunks in your repo. Lots of chunks
  241. in your repo imply a big repository index.
  242. It is possible to tweak the chunker params (see create options) to
  243. influence the amount of chunks being created.
  244. Temporary files (client):
  245. Reading data and metadata from a FUSE mounted repository will consume up to
  246. the size of all deduplicated, small chunks in the repository. Big chunks
  247. won't be locally cached.
  248. Temporary files (server):
  249. None.
  250. Cache files (client only):
  251. Contains the chunks index and files index (plus a collection of single-
  252. archive chunk indexes which might need huge amounts of disk space,
  253. depending on archive count and size - see FAQ about how to reduce).
  254. Network (only for client/server operation):
  255. If your repository is remote, all deduplicated (and optionally compressed/
  256. encrypted) data of course has to go over the connection (``ssh://`` repo url).
  257. If you use a locally mounted network filesystem, additionally some copy
  258. operations used for transaction support also go over the connection. If
  259. you backup multiple sources to one target repository, additional traffic
  260. happens for cache resynchronization.