create.rst.inc 34 KB

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