create.rst.inc 43 KB

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