create.rst.inc 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. .. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!
  2. .. _borg_create:
  3. borg create
  4. -----------
  5. .. code-block:: none
  6. borg [common options] create [options] NAME [PATH...]
  7. .. only:: html
  8. .. class:: borg-options-table
  9. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  10. | **positional arguments** |
  11. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  12. | | ``NAME`` | specify the archive name |
  13. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | | ``PATH`` | paths to archive |
  15. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | **options** |
  17. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | | ``-n``, ``--dry-run`` | do not create a backup archive |
  19. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | | ``-s``, ``--stats`` | print statistics for the created archive |
  21. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | | ``--list`` | output verbose list of items (files, dirs, ...) |
  23. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | | ``--filter STATUSCHARS`` | only display items with the given status characters (see description) |
  25. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | | ``--json`` | output stats as JSON. Implies ``--stats``. |
  27. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | | ``--stdin-name NAME`` | use NAME in archive for stdin data (default: 'stdin') |
  29. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | | ``--stdin-user USER`` | set user USER in archive for stdin data (default: do not store user/uid) |
  31. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | | ``--stdin-group GROUP`` | set group GROUP in archive for stdin data (default: do not store group/gid) |
  33. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | | ``--stdin-mode M`` | set mode to M in archive for stdin data (default: 0660) |
  35. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | | ``--content-from-command`` | interpret PATH as command and store its stdout. See also section Reading from stdin below. |
  37. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | | ``--paths-from-stdin`` | read DELIM-separated list of paths to back up from stdin. All control is external: it will back up all files given - no more, no less. |
  39. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | | ``--paths-from-command`` | interpret PATH as command and treat its output as ``--paths-from-stdin`` |
  41. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | | ``--paths-delimiter DELIM`` | set path delimiter for ``--paths-from-stdin`` and ``--paths-from-command`` (default: ``\n``) |
  43. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | .. class:: borg-common-opt-ref |
  45. | |
  46. | :ref:`common_options` |
  47. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | **Include/Exclude options** |
  49. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | | ``-e PATTERN``, ``--exclude PATTERN`` | exclude paths matching PATTERN |
  51. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | | ``--exclude-from EXCLUDEFILE`` | read exclude patterns from EXCLUDEFILE, one per line |
  53. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | | ``--pattern PATTERN`` | include/exclude paths matching PATTERN |
  55. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | | ``--patterns-from PATTERNFILE`` | read include/exclude patterns from PATTERNFILE, one per line |
  57. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | | ``--exclude-caches`` | exclude directories that contain a CACHEDIR.TAG file (http://www.bford.info/cachedir/spec.html) |
  59. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | | ``--exclude-if-present NAME`` | exclude directories that are tagged by containing a filesystem object with the given NAME |
  61. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | | ``--keep-exclude-tags`` | if tag objects are specified with ``--exclude-if-present``, don't omit the tag objects themselves from the backup archive |
  63. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | **Filesystem options** |
  65. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | | ``-x``, ``--one-file-system`` | stay in the same file system and do not store mount points of other file systems - this might behave different from your expectations, see the description below. |
  67. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | | ``--numeric-ids`` | only store numeric user and group identifiers |
  69. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | | ``--atime`` | do store atime into archive |
  71. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | | ``--noctime`` | do not store ctime into archive |
  73. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | | ``--nobirthtime`` | do not store birthtime (creation date) into archive |
  75. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | | ``--noflags`` | do not read and store flags (e.g. NODUMP, IMMUTABLE) into archive |
  77. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | | ``--noacls`` | do not read and store ACLs into archive |
  79. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | | ``--noxattrs`` | do not read and store xattrs into archive |
  81. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | | ``--sparse`` | detect sparse holes in input (supported only by fixed chunker) |
  83. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | | ``--files-cache MODE`` | operate files cache in MODE. default: ctime,size,inode |
  85. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | | ``--read-special`` | open and read block and char device files as well as FIFOs as if they were regular files. Also follows symlinks pointing to these kinds of files. |
  87. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | **Archive options** |
  89. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | | ``--comment COMMENT`` | add a comment text to the archive |
  91. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | | ``--timestamp TIMESTAMP`` | manually specify the archive creation date/time (yyyy-mm-ddThh:mm:ss[(+|-)HH:MM] format, (+|-)HH:MM is the UTC offset, default: local time zone). Alternatively, give a reference file/directory. |
  93. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | | ``--chunker-params PARAMS`` | specify the chunker parameters (ALGO, CHUNK_MIN_EXP, CHUNK_MAX_EXP, HASH_MASK_BITS, HASH_WINDOW_SIZE). default: buzhash,19,23,21,4095 |
  95. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | | ``-C COMPRESSION``, ``--compression COMPRESSION`` | select compression algorithm, see the output of the "borg help compression" command for details. |
  97. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. .. raw:: html
  99. <script type='text/javascript'>
  100. $(document).ready(function () {
  101. $('.borg-options-table colgroup').remove();
  102. })
  103. </script>
  104. .. only:: latex
  105. NAME
  106. specify the archive name
  107. PATH
  108. paths to archive
  109. options
  110. -n, --dry-run do not create a backup archive
  111. -s, --stats print statistics for the created archive
  112. --list output verbose list of items (files, dirs, ...)
  113. --filter STATUSCHARS only display items with the given status characters (see description)
  114. --json output stats as JSON. Implies ``--stats``.
  115. --stdin-name NAME use NAME in archive for stdin data (default: 'stdin')
  116. --stdin-user USER set user USER in archive for stdin data (default: do not store user/uid)
  117. --stdin-group GROUP set group GROUP in archive for stdin data (default: do not store group/gid)
  118. --stdin-mode M set mode to M in archive for stdin data (default: 0660)
  119. --content-from-command interpret PATH as command and store its stdout. See also section Reading from stdin below.
  120. --paths-from-stdin read DELIM-separated list of paths to back up from stdin. All control is external: it will back up all files given - no more, no less.
  121. --paths-from-command interpret PATH as command and treat its output as ``--paths-from-stdin``
  122. --paths-delimiter DELIM set path delimiter for ``--paths-from-stdin`` and ``--paths-from-command`` (default: ``\n``)
  123. :ref:`common_options`
  124. |
  125. Include/Exclude options
  126. -e PATTERN, --exclude PATTERN exclude paths matching PATTERN
  127. --exclude-from EXCLUDEFILE read exclude patterns from EXCLUDEFILE, one per line
  128. --pattern PATTERN include/exclude paths matching PATTERN
  129. --patterns-from PATTERNFILE read include/exclude patterns from PATTERNFILE, one per line
  130. --exclude-caches exclude directories that contain a CACHEDIR.TAG file (http://www.bford.info/cachedir/spec.html)
  131. --exclude-if-present NAME exclude directories that are tagged by containing a filesystem object with the given NAME
  132. --keep-exclude-tags if tag objects are specified with ``--exclude-if-present``, don't omit the tag objects themselves from the backup archive
  133. Filesystem options
  134. -x, --one-file-system stay in the same file system and do not store mount points of other file systems - this might behave different from your expectations, see the description below.
  135. --numeric-ids only store numeric user and group identifiers
  136. --atime do store atime into archive
  137. --noctime do not store ctime into archive
  138. --nobirthtime do not store birthtime (creation date) into archive
  139. --noflags do not read and store flags (e.g. NODUMP, IMMUTABLE) into archive
  140. --noacls do not read and store ACLs into archive
  141. --noxattrs do not read and store xattrs into archive
  142. --sparse detect sparse holes in input (supported only by fixed chunker)
  143. --files-cache MODE operate files cache in MODE. default: ctime,size,inode
  144. --read-special open and read block and char device files as well as FIFOs as if they were regular files. Also follows symlinks pointing to these kinds of files.
  145. Archive options
  146. --comment COMMENT add a comment text to the archive
  147. --timestamp TIMESTAMP manually specify the archive creation date/time (yyyy-mm-ddThh:mm:ss[(+|-)HH:MM] format, (+|-)HH:MM is the UTC offset, default: local time zone). Alternatively, give a reference file/directory.
  148. --chunker-params PARAMS specify the chunker parameters (ALGO, CHUNK_MIN_EXP, CHUNK_MAX_EXP, HASH_MASK_BITS, HASH_WINDOW_SIZE). default: buzhash,19,23,21,4095
  149. -C COMPRESSION, --compression COMPRESSION select compression algorithm, see the output of the "borg help compression" command for details.
  150. Description
  151. ~~~~~~~~~~~
  152. This command creates a backup archive containing all files found while recursively
  153. traversing all paths specified. Paths are added to the archive as they are given,
  154. that means if relative paths are desired, the command has to be run from the correct
  155. directory.
  156. The slashdot hack in paths (recursion roots) is triggered by using ``/./``:
  157. ``/this/gets/stripped/./this/gets/archived`` means to process that fs object, but
  158. strip the prefix on the left side of ``./`` from the archived items (in this case,
  159. ``this/gets/archived`` will be the path in the archived item).
  160. When giving '-' as path, borg will read data from standard input and create a
  161. file 'stdin' in the created archive from that data. In some cases it's more
  162. appropriate to use --content-from-command, however. See section *Reading from
  163. stdin* below for details.
  164. The archive will consume almost no disk space for files or parts of files that
  165. have already been stored in other archives.
  166. The archive name does NOT need to be unique, you can and should use the same
  167. name for a series of archives. The unique archive identifier is its ID (hash)
  168. and you can abbreviate the ID as long as it is unique.
  169. In the archive name, you may use the following placeholders:
  170. {now}, {utcnow}, {fqdn}, {hostname}, {user} and some others.
  171. Backup speed is increased by not reprocessing files that are already part of
  172. existing archives and weren't modified. The detection of unmodified files is
  173. done by comparing multiple file metadata values with previous values kept in
  174. the files cache.
  175. This comparison can operate in different modes as given by ``--files-cache``:
  176. - ctime,size,inode (default)
  177. - mtime,size,inode (default behaviour of borg versions older than 1.1.0rc4)
  178. - ctime,size (ignore the inode number)
  179. - mtime,size (ignore the inode number)
  180. - rechunk,ctime (all files are considered modified - rechunk, cache ctime)
  181. - rechunk,mtime (all files are considered modified - rechunk, cache mtime)
  182. - disabled (disable the files cache, all files considered modified - rechunk)
  183. inode number: better safety, but often unstable on network filesystems
  184. Normally, detecting file modifications will take inode information into
  185. consideration to improve the reliability of file change detection.
  186. This is problematic for files located on sshfs and similar network file
  187. systems which do not provide stable inode numbers, such files will always
  188. be considered modified. You can use modes without `inode` in this case to
  189. improve performance, but reliability of change detection might be reduced.
  190. ctime vs. mtime: safety vs. speed
  191. - ctime is a rather safe way to detect changes to a file (metadata and contents)
  192. as it can not be set from userspace. But, a metadata-only change will already
  193. update the ctime, so there might be some unnecessary chunking/hashing even
  194. without content changes. Some filesystems do not support ctime (change time).
  195. E.g. doing a chown or chmod to a file will change its ctime.
  196. - mtime usually works and only updates if file contents were changed. But mtime
  197. can be arbitrarily set from userspace, e.g. to set mtime back to the same value
  198. it had before a content change happened. This can be used maliciously as well as
  199. well-meant, but in both cases mtime based cache modes can be problematic.
  200. The mount points of filesystems or filesystem snapshots should be the same for every
  201. creation of a new archive to ensure fast operation. This is because the file cache that
  202. is used to determine changed files quickly uses absolute filenames.
  203. If this is not possible, consider creating a bind mount to a stable location.
  204. The ``--progress`` option shows (from left to right) Original and (uncompressed)
  205. deduplicated size (O and U respectively), then the Number of files (N) processed so far,
  206. followed by the currently processed path.
  207. When using ``--stats``, you will get some statistics about how much data was
  208. added - the "This Archive" deduplicated size there is most interesting as that is
  209. how much your repository will grow. Please note that the "All archives" stats refer to
  210. the state after creation. Also, the ``--stats`` and ``--dry-run`` options are mutually
  211. exclusive because the data is not actually compressed and deduplicated during a dry run.
  212. For more help on include/exclude patterns, see the :ref:`borg_patterns` command output.
  213. For more help on placeholders, see the :ref:`borg_placeholders` command output.
  214. .. man NOTES
  215. The ``--exclude`` patterns are not like tar. In tar ``--exclude`` .bundler/gems will
  216. exclude foo/.bundler/gems. In borg it will not, you need to use ``--exclude``
  217. '\*/.bundler/gems' to get the same effect.
  218. In addition to using ``--exclude`` patterns, it is possible to use
  219. ``--exclude-if-present`` to specify the name of a filesystem object (e.g. a file
  220. or folder name) which, when contained within another folder, will prevent the
  221. containing folder from being backed up. By default, the containing folder and
  222. all of its contents will be omitted from the backup. If, however, you wish to
  223. only include the objects specified by ``--exclude-if-present`` in your backup,
  224. and not include any other contents of the containing folder, this can be enabled
  225. through using the ``--keep-exclude-tags`` option.
  226. The ``-x`` or ``--one-file-system`` option excludes directories, that are mountpoints (and everything in them).
  227. It detects mountpoints by comparing the device number from the output of ``stat()`` of the directory and its
  228. parent directory. Specifically, it excludes directories for which ``stat()`` reports a device number different
  229. from the device number of their parent.
  230. In general: be aware that there are directories with device number different from their parent, which the kernel
  231. does not consider a mountpoint and also the other way around.
  232. Linux examples for this are bind mounts (possibly same device number, but always a mountpoint) and ALL
  233. subvolumes of a btrfs (different device number from parent but not necessarily a mountpoint).
  234. macOS examples are the apfs mounts of a typical macOS installation.
  235. Therefore, when using ``--one-file-system``, you should double-check that the backup works as intended.
  236. .. _list_item_flags:
  237. Item flags
  238. ++++++++++
  239. ``--list`` outputs a list of all files, directories and other
  240. file system items it considered (no matter whether they had content changes
  241. or not). For each item, it prefixes a single-letter flag that indicates type
  242. and/or status of the item.
  243. If you are interested only in a subset of that output, you can give e.g.
  244. ``--filter=AME`` and it will only show regular files with A, M or E status (see
  245. below).
  246. A uppercase character represents the status of a regular file relative to the
  247. "files" cache (not relative to the repo -- this is an issue if the files cache
  248. is not used). Metadata is stored in any case and for 'A' and 'M' also new data
  249. chunks are stored. For 'U' all data chunks refer to already existing chunks.
  250. - 'A' = regular file, added (see also :ref:`a_status_oddity` in the FAQ)
  251. - 'M' = regular file, modified
  252. - 'U' = regular file, unchanged
  253. - 'C' = regular file, it changed while we backed it up
  254. - 'E' = regular file, an error happened while accessing/reading *this* file
  255. A lowercase character means a file type other than a regular file,
  256. borg usually just stores their metadata:
  257. - 'd' = directory
  258. - 'b' = block device
  259. - 'c' = char device
  260. - 'h' = regular file, hardlink (to already seen inodes)
  261. - 's' = symlink
  262. - 'f' = fifo
  263. Other flags used include:
  264. - '+' = included, item would be backed up (if not in dry-run mode)
  265. - '-' = excluded, item would not be / was not backed up
  266. - 'i' = backup data was read from standard input (stdin)
  267. - '?' = missing status code (if you see this, please file a bug report!)
  268. Reading backup data from stdin
  269. ++++++++++++++++++++++++++++++
  270. There are two methods to read from stdin. Either specify ``-`` as path and
  271. pipe directly to borg::
  272. backup-vm --id myvm --stdout | borg create --repo REPO ARCHIVE -
  273. Or use ``--content-from-command`` to have Borg manage the execution of the
  274. command and piping. If you do so, the first PATH argument is interpreted
  275. as command to execute and any further arguments are treated as arguments
  276. to the command::
  277. borg create --content-from-command --repo REPO ARCHIVE -- backup-vm --id myvm --stdout
  278. ``--`` is used to ensure ``--id`` and ``--stdout`` are **not** considered
  279. arguments to ``borg`` but rather ``backup-vm``.
  280. The difference between the two approaches is that piping to borg creates an
  281. archive even if the command piping to borg exits with a failure. In this case,
  282. **one can end up with truncated output being backed up**. Using
  283. ``--content-from-command``, in contrast, borg is guaranteed to fail without
  284. creating an archive should the command fail. The command is considered failed
  285. when it returned a non-zero exit code.
  286. Reading from stdin yields just a stream of data without file metadata
  287. associated with it, and the files cache is not needed at all. So it is
  288. safe to disable it via ``--files-cache disabled`` and speed up backup
  289. creation a bit.
  290. By default, the content read from stdin is stored in a file called 'stdin'.
  291. Use ``--stdin-name`` to change the name.
  292. Feeding all file paths from externally
  293. ++++++++++++++++++++++++++++++++++++++
  294. Usually, you give a starting path (recursion root) to borg and then borg
  295. automatically recurses, finds and backs up all fs objects contained in
  296. there (optionally considering include/exclude rules).
  297. If you need more control and you want to give every single fs object path
  298. to borg (maybe implementing your own recursion or your own rules), you can use
  299. ``--paths-from-stdin`` or ``--paths-from-command`` (with the latter, borg will
  300. fail to create an archive should the command fail).
  301. Borg supports paths with the slashdot hack to strip path prefixes here also.
  302. So, be careful not to unintentionally trigger that.