create.rst.inc 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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] ARCHIVE [PATH...]
  7. .. only:: html
  8. .. class:: borg-options-table
  9. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  10. | **positional arguments** |
  11. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  12. | | ``ARCHIVE`` | name of archive to create (must be also a valid directory name) |
  13. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | | ``PATH`` | paths to archive |
  15. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | **optional arguments** |
  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. | | ``--no-cache-sync`` | experimental: do not synchronize the cache. Implies not using the files cache. |
  29. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | | ``--stdin-name NAME`` | use NAME in archive for stdin data (default: 'stdin') |
  31. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | | ``--content-from-command`` | interpret PATH as command and store its stdout. See also section Reading from stdin below. |
  33. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | .. class:: borg-common-opt-ref |
  35. | |
  36. | :ref:`common_options` |
  37. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | **Exclusion options** |
  39. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | | ``-e PATTERN``, ``--exclude PATTERN`` | exclude paths matching PATTERN |
  41. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | | ``--exclude-from EXCLUDEFILE`` | read exclude patterns from EXCLUDEFILE, one per line |
  43. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | | ``--pattern PATTERN`` | experimental: include/exclude paths matching PATTERN |
  45. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | | ``--patterns-from PATTERNFILE`` | experimental: read include/exclude patterns from PATTERNFILE, one per line |
  47. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | | ``--exclude-caches`` | exclude directories that contain a CACHEDIR.TAG file (http://www.bford.info/cachedir/spec.html) |
  49. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | | ``--exclude-if-present NAME`` | exclude directories that are tagged by containing a filesystem object with the given NAME |
  51. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | | ``--keep-exclude-tags`` | if tag objects are specified with ``--exclude-if-present``, don't omit the tag objects themselves from the backup archive |
  53. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | | ``--exclude-nodump`` | exclude files flagged NODUMP |
  55. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | **Filesystem options** |
  57. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | | ``-x``, ``--one-file-system`` | stay in the same file system and do not store mount points of other file systems |
  59. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | | ``--numeric-owner`` | only store numeric user and group identifiers |
  61. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | | ``--noatime`` | do not store atime into archive |
  63. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | | ``--atime`` | do store atime into archive |
  65. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | | ``--noctime`` | do not store ctime into archive |
  67. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | | ``--nobirthtime`` | do not store birthtime (creation date) into archive |
  69. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | | ``--nobsdflags`` | deprecated, use ``--noflags`` instead |
  71. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | | ``--noflags`` | do not read and store flags (e.g. NODUMP, IMMUTABLE) into archive |
  73. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | | ``--files-cache MODE`` | operate files cache in MODE. default: ctime,size,inode |
  75. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | | ``--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. |
  77. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | **Archive options** |
  79. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | | ``--comment COMMENT`` | add a comment text to the archive |
  81. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | | ``--timestamp TIMESTAMP`` | manually specify the archive creation date/time (UTC, yyyy-mm-ddThh:mm:ss format). Alternatively, give a reference file/directory. |
  83. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | | ``-c SECONDS``, ``--checkpoint-interval SECONDS`` | write checkpoint every SECONDS seconds (Default: 1800) |
  85. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | | ``--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 |
  87. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | | ``-C COMPRESSION``, ``--compression COMPRESSION`` | select compression algorithm, see the output of the "borg help compression" command for details. |
  89. +-------------------------------------------------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  90. .. raw:: html
  91. <script type='text/javascript'>
  92. $(document).ready(function () {
  93. $('.borg-options-table colgroup').remove();
  94. })
  95. </script>
  96. .. only:: latex
  97. ARCHIVE
  98. name of archive to create (must be also a valid directory name)
  99. PATH
  100. paths to archive
  101. optional arguments
  102. -n, --dry-run do not create a backup archive
  103. -s, --stats print statistics for the created archive
  104. --list output verbose list of items (files, dirs, ...)
  105. --filter STATUSCHARS only display items with the given status characters (see description)
  106. --json output stats as JSON. Implies ``--stats``.
  107. --no-cache-sync experimental: do not synchronize the cache. Implies not using the files cache.
  108. --stdin-name NAME use NAME in archive for stdin data (default: 'stdin')
  109. --content-from-command interpret PATH as command and store its stdout. See also section Reading from stdin below.
  110. :ref:`common_options`
  111. |
  112. Exclusion options
  113. -e PATTERN, --exclude PATTERN exclude paths matching PATTERN
  114. --exclude-from EXCLUDEFILE read exclude patterns from EXCLUDEFILE, one per line
  115. --pattern PATTERN experimental: include/exclude paths matching PATTERN
  116. --patterns-from PATTERNFILE experimental: read include/exclude patterns from PATTERNFILE, one per line
  117. --exclude-caches exclude directories that contain a CACHEDIR.TAG file (http://www.bford.info/cachedir/spec.html)
  118. --exclude-if-present NAME exclude directories that are tagged by containing a filesystem object with the given NAME
  119. --keep-exclude-tags if tag objects are specified with ``--exclude-if-present``, don't omit the tag objects themselves from the backup archive
  120. --exclude-nodump exclude files flagged NODUMP
  121. Filesystem options
  122. -x, --one-file-system stay in the same file system and do not store mount points of other file systems
  123. --numeric-owner only store numeric user and group identifiers
  124. --noatime do not store atime into archive
  125. --atime do store atime into archive
  126. --noctime do not store ctime into archive
  127. --nobirthtime do not store birthtime (creation date) into archive
  128. --nobsdflags deprecated, use ``--noflags`` instead
  129. --noflags do not read and store flags (e.g. NODUMP, IMMUTABLE) into archive
  130. --files-cache MODE operate files cache in MODE. default: ctime,size,inode
  131. --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.
  132. Archive options
  133. --comment COMMENT add a comment text to the archive
  134. --timestamp TIMESTAMP manually specify the archive creation date/time (UTC, yyyy-mm-ddThh:mm:ss format). Alternatively, give a reference file/directory.
  135. -c SECONDS, --checkpoint-interval SECONDS write checkpoint every SECONDS seconds (Default: 1800)
  136. --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
  137. -C COMPRESSION, --compression COMPRESSION select compression algorithm, see the output of the "borg help compression" command for details.
  138. Description
  139. ~~~~~~~~~~~
  140. This command creates a backup archive containing all files found while recursively
  141. traversing all paths specified. Paths are added to the archive as they are given,
  142. that means if relative paths are desired, the command has to be run from the correct
  143. directory.
  144. When giving '-' as path, borg will read data from standard input and create a
  145. file 'stdin' in the created archive from that data. In some cases it's more
  146. appropriate to use --content-from-command, however. See section *Reading from
  147. stdin* below for details.
  148. The archive will consume almost no disk space for files or parts of files that
  149. have already been stored in other archives.
  150. The archive name needs to be unique. It must not end in '.checkpoint' or
  151. '.checkpoint.N' (with N being a number), because these names are used for
  152. checkpoints and treated in special ways.
  153. In the archive name, you may use the following placeholders:
  154. {now}, {utcnow}, {fqdn}, {hostname}, {user} and some others.
  155. Backup speed is increased by not reprocessing files that are already part of
  156. existing archives and weren't modified. The detection of unmodified files is
  157. done by comparing multiple file metadata values with previous values kept in
  158. the files cache.
  159. This comparison can operate in different modes as given by ``--files-cache``:
  160. - ctime,size,inode (default)
  161. - mtime,size,inode (default behaviour of borg versions older than 1.1.0rc4)
  162. - ctime,size (ignore the inode number)
  163. - mtime,size (ignore the inode number)
  164. - rechunk,ctime (all files are considered modified - rechunk, cache ctime)
  165. - rechunk,mtime (all files are considered modified - rechunk, cache mtime)
  166. - disabled (disable the files cache, all files considered modified - rechunk)
  167. inode number: better safety, but often unstable on network filesystems
  168. Normally, detecting file modifications will take inode information into
  169. consideration to improve the reliability of file change detection.
  170. This is problematic for files located on sshfs and similar network file
  171. systems which do not provide stable inode numbers, such files will always
  172. be considered modified. You can use modes without `inode` in this case to
  173. improve performance, but reliability of change detection might be reduced.
  174. ctime vs. mtime: safety vs. speed
  175. - ctime is a rather safe way to detect changes to a file (metadata and contents)
  176. as it can not be set from userspace. But, a metadata-only change will already
  177. update the ctime, so there might be some unnecessary chunking/hashing even
  178. without content changes. Some filesystems do not support ctime (change time).
  179. - mtime usually works and only updates if file contents were changed. But mtime
  180. can be arbitrarily set from userspace, e.g. to set mtime back to the same value
  181. it had before a content change happened. This can be used maliciously as well as
  182. well-meant, but in both cases mtime based cache modes can be problematic.
  183. The mount points of filesystems or filesystem snapshots should be the same for every
  184. creation of a new archive to ensure fast operation. This is because the file cache that
  185. is used to determine changed files quickly uses absolute filenames.
  186. If this is not possible, consider creating a bind mount to a stable location.
  187. The ``--progress`` option shows (from left to right) Original, Compressed and Deduplicated
  188. (O, C and D, respectively), then the Number of files (N) processed so far, followed by
  189. the currently processed path.
  190. When using ``--stats``, you will get some statistics about how much data was
  191. added - the "This Archive" deduplicated size there is most interesting as that is
  192. how much your repository will grow. Please note that the "All archives" stats refer to
  193. the state after creation. Also, the ``--stats`` and ``--dry-run`` options are mutually
  194. exclusive because the data is not actually compressed and deduplicated during a dry run.
  195. See the output of the "borg help patterns" command for more help on exclude patterns.
  196. See the output of the "borg help placeholders" command for more help on placeholders.
  197. .. man NOTES
  198. The ``--exclude`` patterns are not like tar. In tar ``--exclude`` .bundler/gems will
  199. exclude foo/.bundler/gems. In borg it will not, you need to use ``--exclude``
  200. '\*/.bundler/gems' to get the same effect. See ``borg help patterns`` for
  201. more information.
  202. In addition to using ``--exclude`` patterns, it is possible to use
  203. ``--exclude-if-present`` to specify the name of a filesystem object (e.g. a file
  204. or folder name) which, when contained within another folder, will prevent the
  205. containing folder from being backed up. By default, the containing folder and
  206. all of its contents will be omitted from the backup. If, however, you wish to
  207. only include the objects specified by ``--exclude-if-present`` in your backup,
  208. and not include any other contents of the containing folder, this can be enabled
  209. through using the ``--keep-exclude-tags`` option.
  210. .. _list_item_flags:
  211. Item flags
  212. ++++++++++
  213. ``--list`` outputs a list of all files, directories and other
  214. file system items it considered (no matter whether they had content changes
  215. or not). For each item, it prefixes a single-letter flag that indicates type
  216. and/or status of the item.
  217. If you are interested only in a subset of that output, you can give e.g.
  218. ``--filter=AME`` and it will only show regular files with A, M or E status (see
  219. below).
  220. A uppercase character represents the status of a regular file relative to the
  221. "files" cache (not relative to the repo -- this is an issue if the files cache
  222. is not used). Metadata is stored in any case and for 'A' and 'M' also new data
  223. chunks are stored. For 'U' all data chunks refer to already existing chunks.
  224. - 'A' = regular file, added (see also :ref:`a_status_oddity` in the FAQ)
  225. - 'M' = regular file, modified
  226. - 'U' = regular file, unchanged
  227. - 'C' = regular file, it changed while we backed it up
  228. - 'E' = regular file, an error happened while accessing/reading *this* file
  229. A lowercase character means a file type other than a regular file,
  230. borg usually just stores their metadata:
  231. - 'd' = directory
  232. - 'b' = block device
  233. - 'c' = char device
  234. - 'h' = regular file, hardlink (to already seen inodes)
  235. - 's' = symlink
  236. - 'f' = fifo
  237. Other flags used include:
  238. - 'i' = backup data was read from standard input (stdin)
  239. - '-' = dry run, item was *not* backed up
  240. - 'x' = excluded, item was *not* backed up
  241. - '?' = missing status code (if you see this, please file a bug report!)
  242. Reading from stdin
  243. ++++++++++++++++++
  244. There are two methods to read from stdin. Either specify ``-`` as path and
  245. pipe directly to borg::
  246. backup-vm --id myvm --stdout | borg create REPO::ARCHIVE -
  247. Or use ``--content-from-command`` to have Borg manage the execution of the
  248. command and piping. If you do so, the first PATH argument is interpreted
  249. as command to execute and any further arguments are treated as arguments
  250. to the command::
  251. borg create --content-from-command REPO::ARCHIVE -- backup-vm --id myvm --stdout
  252. ``--`` is used to ensure ``--id`` and ``--stdout`` are **not** considered
  253. arguments to ``borg`` but rather ``backup-vm``.
  254. The difference between the two approaches is that piping to borg creates an
  255. archive even if the command piping to borg exits with a failure. In this case,
  256. **one can end up with truncated output being backed up**. Using
  257. ``--content-from-command``, in contrast, borg is guaranteed to fail without
  258. creating an archive should the command fail. The command is considered failed
  259. when it returned a non-zero exit code.
  260. Reading from stdin yields just a stream of data without file metadata
  261. associated with it, and the files cache is not needed at all. So it is
  262. safe to disable it via ``--files-cache disabled`` and speed up backup
  263. creation a bit.
  264. By default, the content read from stdin is stored in a file called 'stdin'.
  265. Use ``--stdin-name`` to change the name.