usage_general.rst.inc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. Positional Arguments and Options: Order matters
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. Borg only supports taking options (``-s`` and ``--progress`` in the example)
  4. to the left or right of all positional arguments (``repo::archive`` and ``path``
  5. in the example), but not in between them:
  6. ::
  7. borg create -s --progress repo::archive path # good and preferred
  8. borg create repo::archive path -s --progress # also works
  9. borg create -s repo::archive path --progress # works, but ugly
  10. borg create repo::archive -s --progress path # BAD
  11. This is due to a problem in the argparse module: http://bugs.python.org/issue15112
  12. Repository URLs
  13. ~~~~~~~~~~~~~~~
  14. **Local filesystem** (or locally mounted network filesystem):
  15. ``/path/to/repo`` - filesystem path to repo directory, absolute path
  16. ``path/to/repo`` - filesystem path to repo directory, relative path
  17. Also, stuff like ``~/path/to/repo`` or ``~other/path/to/repo`` works (this is
  18. expanded by your shell).
  19. Note: you may also prepend a ``file://`` to a filesystem path to get URL style.
  20. **Remote repositories** accessed via ssh user@host:
  21. ``user@host:/path/to/repo`` - remote repo, absolute path
  22. ``ssh://user@host:port/path/to/repo`` - same, alternative syntax, port can be given
  23. **Remote repositories with relative paths** can be given using this syntax:
  24. ``user@host:path/to/repo`` - path relative to current directory
  25. ``user@host:~/path/to/repo`` - path relative to user's home directory
  26. ``user@host:~other/path/to/repo`` - path relative to other's home directory
  27. Note: giving ``user@host:/./path/to/repo`` or ``user@host:/~/path/to/repo`` or
  28. ``user@host:/~other/path/to/repo`` is also supported, but not required here.
  29. **Remote repositories with relative paths, alternative syntax with port**:
  30. ``ssh://user@host:port/./path/to/repo`` - path relative to current directory
  31. ``ssh://user@host:port/~/path/to/repo`` - path relative to user's home directory
  32. ``ssh://user@host:port/~other/path/to/repo`` - path relative to other's home directory
  33. If you frequently need the same repo URL, it is a good idea to set the
  34. ``BORG_REPO`` environment variable to set a default for the repo URL:
  35. ::
  36. export BORG_REPO='ssh://user@host:port/path/to/repo'
  37. Then just leave away the repo URL if only a repo URL is needed and you want
  38. to use the default - it will be read from BORG_REPO then.
  39. Use ``::`` syntax to give the repo URL when syntax requires giving a positional
  40. argument for the repo (e.g. ``borg mount :: /mnt``).
  41. Repository / Archive Locations
  42. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  43. Many commands want either a repository (just give the repo URL, see above) or
  44. an archive location, which is a repo URL followed by ``::archive_name``.
  45. Archive names must not contain the ``/`` (slash) character. For simplicity,
  46. maybe also avoid blanks or other characters that have special meaning on the
  47. shell or in a filesystem (borg mount will use the archive name as directory
  48. name).
  49. If you have set BORG_REPO (see above) and an archive location is needed, use
  50. ``::archive_name`` - the repo URL part is then read from BORG_REPO.
  51. Type of log output
  52. ~~~~~~~~~~~~~~~~~~
  53. The log level of the builtin logging configuration defaults to WARNING.
  54. This is because we want Borg to be mostly silent and only output
  55. warnings, errors and critical messages, unless output has been requested
  56. by supplying an option that implies output (e.g. ``--list`` or ``--progress``).
  57. Log levels: DEBUG < INFO < WARNING < ERROR < CRITICAL
  58. Use ``--debug`` to set DEBUG log level -
  59. to get debug, info, warning, error and critical level output.
  60. Use ``--info`` (or ``-v`` or ``--verbose``) to set INFO log level -
  61. to get info, warning, error and critical level output.
  62. Use ``--warning`` (default) to set WARNING log level -
  63. to get warning, error and critical level output.
  64. Use ``--error`` to set ERROR log level -
  65. to get error and critical level output.
  66. Use ``--critical`` to set CRITICAL log level -
  67. to get critical level output.
  68. While you can set misc. log levels, do not expect that every command will
  69. give different output on different log levels - it's just a possibility.
  70. .. warning:: Options ``--critical`` and ``--error`` are provided for completeness,
  71. their usage is not recommended as you might miss important information.
  72. Return codes
  73. ~~~~~~~~~~~~
  74. Borg can exit with the following return codes (rc):
  75. =========== =======
  76. Return code Meaning
  77. =========== =======
  78. 0 success (logged as INFO)
  79. 1 warning (operation reached its normal end, but there were warnings --
  80. you should check the log, logged as WARNING)
  81. 2 error (like a fatal error, a local or remote exception, the operation
  82. did not reach its normal end, logged as ERROR)
  83. 128+N killed by signal N (e.g. 137 == kill -9)
  84. =========== =======
  85. If you use ``--show-rc``, the return code is also logged at the indicated
  86. level as the last log entry.
  87. .. _env_vars:
  88. Environment Variables
  89. ~~~~~~~~~~~~~~~~~~~~~
  90. Borg uses some environment variables for automation:
  91. General:
  92. BORG_REPO
  93. When set, use the value to give the default repository location. If a command needs an archive
  94. parameter, you can abbreviate as ``::archive``. If a command needs a repository parameter, you
  95. can either leave it away or abbreviate as ``::``, if a positional parameter is required.
  96. BORG_PASSPHRASE
  97. When set, use the value to answer the passphrase question for encrypted repositories.
  98. It is used when a passphrase is needed to access an encrypted repo as well as when a new
  99. passphrase should be initially set when initializing an encrypted repo.
  100. See also BORG_NEW_PASSPHRASE.
  101. BORG_PASSCOMMAND
  102. When set, use the standard output of the command (trailing newlines are stripped) to answer the
  103. passphrase question for encrypted repositories.
  104. It is used when a passphrase is needed to access an encrypted repo as well as when a new
  105. passphrase should be initially set when initializing an encrypted repo.
  106. If BORG_PASSPHRASE is also set, it takes precedence.
  107. See also BORG_NEW_PASSPHRASE.
  108. BORG_NEW_PASSPHRASE
  109. When set, use the value to answer the passphrase question when a **new** passphrase is asked for.
  110. This variable is checked first. If it is not set, BORG_PASSPHRASE and BORG_PASSCOMMAND will also
  111. be checked.
  112. Main usecase for this is to fully automate ``borg change-passphrase``.
  113. BORG_DISPLAY_PASSPHRASE
  114. When set, use the value to answer the "display the passphrase for verification" question when defining a new passphrase for encrypted repositories.
  115. BORG_HOSTNAME_IS_UNIQUE=no
  116. Borg assumes that it can derive a unique hostname / identity (see ``borg debug info``).
  117. If this is not the case or you do not want Borg to automatically remove stale locks,
  118. set this to *no*.
  119. BORG_LOGGING_CONF
  120. When set, use the given filename as INI_-style logging configuration.
  121. BORG_RSH
  122. When set, use this command instead of ``ssh``. This can be used to specify ssh options, such as
  123. a custom identity file ``ssh -i /path/to/private/key``. See ``man ssh`` for other options.
  124. BORG_REMOTE_PATH
  125. When set, use the given path as borg executable on the remote (defaults to "borg" if unset).
  126. Using ``--remote-path PATH`` commandline option overrides the environment variable.
  127. BORG_FILES_CACHE_TTL
  128. When set to a numeric value, this determines the maximum "time to live" for the files cache
  129. entries (default: 20). The files cache is used to quickly determine whether a file is unchanged.
  130. The FAQ explains this more detailed in: :ref:`always_chunking`
  131. TMPDIR
  132. where temporary files are stored (might need a lot of temporary space for some operations)
  133. Some automatic "answerers" (if set, they automatically answer confirmation questions):
  134. BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no (or =yes)
  135. For "Warning: Attempting to access a previously unknown unencrypted repository"
  136. BORG_RELOCATED_REPO_ACCESS_IS_OK=no (or =yes)
  137. For "Warning: The repository at location ... was previously located at ..."
  138. BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  139. For "Warning: 'check --repair' is an experimental feature that might result in data loss."
  140. BORG_DELETE_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  141. For "You requested to completely DELETE the repository *including* all archives it contains:"
  142. BORG_RECREATE_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
  143. For "recreate is an experimental feature."
  144. Note: answers are case sensitive. setting an invalid answer value might either give the default
  145. answer or ask you interactively, depending on whether retries are allowed (they by default are
  146. allowed). So please test your scripts interactively before making them a non-interactive script.
  147. Directories and files:
  148. BORG_BASE_DIR
  149. Default to '$HOME', '~$USER', '~' (in that order)'.
  150. If we refer to ~ below, we in fact mean BORG_BASE_DIR.
  151. BORG_CONFIG_DIR
  152. Default to '~/.config/borg'. This directory contains the whole config directories.
  153. BORG_CACHE_DIR
  154. Default to '~/.cache/borg'. This directory contains the local cache and might need a lot
  155. of space for dealing with big repositories.
  156. BORG_SECURITY_DIR
  157. Default to '~/.config/borg/security'. This directory contains information borg uses to
  158. track its usage of NONCES ("numbers used once" - usually in encryption context) and other
  159. security relevant data.
  160. BORG_KEYS_DIR
  161. Default to '~/.config/borg/keys'. This directory contains keys for encrypted repositories.
  162. BORG_KEY_FILE
  163. When set, use the given filename as repository key file.
  164. Building:
  165. BORG_OPENSSL_PREFIX
  166. Adds given OpenSSL header file directory to the default locations (setup.py).
  167. BORG_LIBLZ4_PREFIX
  168. Adds given prefix directory to the default locations. If a 'include/lz4.h' is found Borg
  169. will be linked against the system liblz4 instead of a bundled implementation. (setup.py)
  170. BORG_LIBB2_PREFIX
  171. Adds given prefix directory to the default locations. If a 'include/blake2.h' is found Borg
  172. will be linked against the system libb2 instead of a bundled implementation. (setup.py)
  173. Please note:
  174. - be very careful when using the "yes" sayers, the warnings with prompt exist for your / your data's security/safety
  175. - also be very careful when putting your passphrase into a script, make sure it has appropriate file permissions
  176. (e.g. mode 600, root:root).
  177. .. _INI: https://docs.python.org/3.5/library/logging.config.html#configuration-file-format
  178. .. _file-systems:
  179. File systems
  180. ~~~~~~~~~~~~
  181. We strongly recommend against using Borg (or any other database-like
  182. software) on non-journaling file systems like FAT, since it is not
  183. possible to assume any consistency in case of power failures (or a
  184. sudden disconnect of an external drive or similar failures).
  185. While Borg uses a data store that is resilient against these failures
  186. when used on journaling file systems, it is not possible to guarantee
  187. this with some hardware -- independent of the software used. We don't
  188. know a list of affected hardware.
  189. If you are suspicious whether your Borg repository is still consistent
  190. and readable after one of the failures mentioned above occurred, run
  191. ``borg check --verify-data`` to make sure it is consistent.
  192. .. rubric:: Requirements for Borg repository file systems
  193. - Long file names
  194. - At least three directory levels with short names
  195. - Typically, file sizes up to a few hundred MB.
  196. Large repositories may require large files (>2 GB).
  197. - Up to 1000 files per directory (10000 for repositories initialized with Borg 1.0)
  198. - mkdir(2) should be atomic, since it is used for locking
  199. - Hardlinks are needed for :ref:`borg_upgrade` ``--inplace``
  200. Units
  201. ~~~~~
  202. To display quantities, Borg takes care of respecting the
  203. usual conventions of scale. Disk sizes are displayed in `decimal
  204. <https://en.wikipedia.org/wiki/Decimal>`_, using powers of ten (so
  205. ``kB`` means 1000 bytes). For memory usage, `binary prefixes
  206. <https://en.wikipedia.org/wiki/Binary_prefix>`_ are used, and are
  207. indicated using the `IEC binary prefixes
  208. <https://en.wikipedia.org/wiki/IEC_80000-13#Prefixes_for_binary_multiples>`_,
  209. using powers of two (so ``KiB`` means 1024 bytes).
  210. Date and Time
  211. ~~~~~~~~~~~~~
  212. We format date and time conforming to ISO-8601, that is: YYYY-MM-DD and
  213. HH:MM:SS (24h clock).
  214. For more information about that, see: https://xkcd.com/1179/
  215. Unless otherwise noted, we display local date and time.
  216. Internally, we store and process date and time as UTC.
  217. Resource Usage
  218. ~~~~~~~~~~~~~~
  219. Borg might use a lot of resources depending on the size of the data set it is dealing with.
  220. If one uses Borg in a client/server way (with a ssh: repository),
  221. the resource usage occurs in part on the client and in another part on the
  222. server.
  223. If one uses Borg as a single process (with a filesystem repo),
  224. all the resource usage occurs in that one process, so just add up client +
  225. server to get the approximate resource usage.
  226. CPU client:
  227. borg create: does chunking, hashing, compression, crypto (high CPU usage)
  228. chunks cache sync: quite heavy on CPU, doing lots of hashtable operations.
  229. borg extract: crypto, decompression (medium to high CPU usage)
  230. borg check: similar to extract, but depends on options given.
  231. borg prune / borg delete archive: low to medium CPU usage
  232. borg delete repo: done on the server
  233. It won't go beyond 100% of 1 core as the code is currently single-threaded.
  234. Especially higher zlib and lzma compression levels use significant amounts
  235. of CPU cycles. Crypto might be cheap on the CPU (if hardware accelerated) or
  236. expensive (if not).
  237. CPU server:
  238. It usually doesn't need much CPU, it just deals with the key/value store
  239. (repository) and uses the repository index for that.
  240. borg check: the repository check computes the checksums of all chunks
  241. (medium CPU usage)
  242. borg delete repo: low CPU usage
  243. CPU (only for client/server operation):
  244. When using borg in a client/server way with a ssh:-type repo, the ssh
  245. processes used for the transport layer will need some CPU on the client and
  246. on the server due to the crypto they are doing - esp. if you are pumping
  247. big amounts of data.
  248. Memory (RAM) client:
  249. The chunks index and the files index are read into memory for performance
  250. reasons. Might need big amounts of memory (see below).
  251. Compression, esp. lzma compression with high levels might need substantial
  252. amounts of memory.
  253. Memory (RAM) server:
  254. The server process will load the repository index into memory. Might need
  255. considerable amounts of memory, but less than on the client (see below).
  256. Chunks index (client only):
  257. Proportional to the amount of data chunks in your repo. Lots of chunks
  258. in your repo imply a big chunks index.
  259. It is possible to tweak the chunker params (see create options).
  260. Files index (client only):
  261. Proportional to the amount of files in your last backups. Can be switched
  262. off (see create options), but next backup might be much slower if you do.
  263. The speed benefit of using the files cache is proportional to file size.
  264. Repository index (server only):
  265. Proportional to the amount of data chunks in your repo. Lots of chunks
  266. in your repo imply a big repository index.
  267. It is possible to tweak the chunker params (see create options) to
  268. influence the amount of chunks being created.
  269. Temporary files (client):
  270. Reading data and metadata from a FUSE mounted repository will consume up to
  271. the size of all deduplicated, small chunks in the repository. Big chunks
  272. won't be locally cached.
  273. Temporary files (server):
  274. None.
  275. Cache files (client only):
  276. Contains the chunks index and files index (plus a collection of single-
  277. archive chunk indexes which might need huge amounts of disk space,
  278. depending on archive count and size - see FAQ about how to reduce).
  279. Network (only for client/server operation):
  280. If your repository is remote, all deduplicated (and optionally compressed/
  281. encrypted) data of course has to go over the connection (``ssh://`` repo url).
  282. If you use a locally mounted network filesystem, additionally some copy
  283. operations used for transaction support also go over the connection. If
  284. you backup multiple sources to one target repository, additional traffic
  285. happens for cache resynchronization.
  286. .. _platforms:
  287. Support for file metadata
  288. ~~~~~~~~~~~~~~~~~~~~~~~~~
  289. Besides regular file and directory structures, Borg can preserve
  290. * symlinks (stored as symlink, the symlink is not followed)
  291. * special files:
  292. * character and block device files (restored via mknod)
  293. * FIFOs ("named pipes")
  294. * special file *contents* can be backed up in ``--read-special`` mode.
  295. By default the metadata to create them with mknod(2), mkfifo(2) etc. is stored.
  296. * hardlinked regular files, devices, FIFOs (considering all items in the same archive)
  297. * timestamps in nanosecond precision: mtime, atime, ctime
  298. * other timestamps: birthtime (on platforms supporting it)
  299. * permissions:
  300. * IDs of owning user and owning group
  301. * names of owning user and owning group (if the IDs can be resolved)
  302. * Unix Mode/Permissions (u/g/o permissions, suid, sgid, sticky)
  303. On some platforms additional features are supported:
  304. .. Yes/No's are grouped by reason/mechanism/reference.
  305. +------------------+----------+-----------+------------+
  306. | Platform | ACLs | xattr | Flags |
  307. | | [#acls]_ | [#xattr]_ | [#flags]_ |
  308. +==================+==========+===========+============+
  309. | Linux | Yes | Yes | Yes [1]_ |
  310. +------------------+----------+-----------+------------+
  311. | Mac OS X | Yes | Yes | Yes (all) |
  312. +------------------+----------+-----------+ |
  313. | FreeBSD | Yes | Yes | |
  314. +------------------+----------+-----------+ |
  315. | OpenBSD | n/a | n/a | |
  316. +------------------+----------+-----------+ |
  317. | NetBSD | n/a | No [2]_ | |
  318. +------------------+----------+-----------+------------+
  319. | Solaris 11 | No [3]_ | n/a |
  320. +------------------+ | |
  321. | OpenIndiana | | |
  322. +------------------+----------+-----------+------------+
  323. | Windows (cygwin) | No [4]_ | No | No |
  324. +------------------+----------+-----------+------------+
  325. Other Unix-like operating systems may work as well, but have not been tested at all.
  326. Note that most of the platform-dependent features also depend on the file system.
  327. For example, ntfs-3g on Linux isn't able to convey NTFS ACLs.
  328. .. [1] Only "nodump", "immutable", "compressed" and "append" are supported.
  329. Feature request :issue:`618` for more flags.
  330. .. [2] Feature request :issue:`1332`
  331. .. [3] Feature request :issue:`1337`
  332. .. [4] Cygwin tries to map NTFS ACLs to permissions with varying degress of success.
  333. .. [#acls] The native access control list mechanism of the OS. This normally limits access to
  334. non-native ACLs. For example, NTFS ACLs aren't completely accessible on Linux with ntfs-3g.
  335. .. [#xattr] extended attributes; key-value pairs attached to a file, mainly used by the OS.
  336. This includes resource forks on Mac OS X.
  337. .. [#flags] aka *BSD flags*. The Linux set of flags [1]_ is portable across platforms.
  338. The BSDs define additional flags.