borg-create.1 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH BORG-CREATE 1 "2020-10-06" "" "borg backup tool"
  4. .SH NAME
  5. borg-create \- Create new archive
  6. .
  7. .nr rst2man-indent-level 0
  8. .
  9. .de1 rstReportMargin
  10. \\$1 \\n[an-margin]
  11. level \\n[rst2man-indent-level]
  12. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  13. -
  14. \\n[rst2man-indent0]
  15. \\n[rst2man-indent1]
  16. \\n[rst2man-indent2]
  17. ..
  18. .de1 INDENT
  19. .\" .rstReportMargin pre:
  20. . RS \\$1
  21. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  22. . nr rst2man-indent-level +1
  23. .\" .rstReportMargin post:
  24. ..
  25. .de UNINDENT
  26. . RE
  27. .\" indent \\n[an-margin]
  28. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  29. .nr rst2man-indent-level -1
  30. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  31. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  32. ..
  33. .SH SYNOPSIS
  34. .sp
  35. borg [common options] create [options] ARCHIVE [PATH...]
  36. .SH DESCRIPTION
  37. .sp
  38. This command creates a backup archive containing all files found while recursively
  39. traversing all paths specified. Paths are added to the archive as they are given,
  40. that means if relative paths are desired, the command has to be run from the correct
  41. directory.
  42. .sp
  43. When giving \(aq\-\(aq as path, borg will read data from standard input and create a
  44. file \(aqstdin\(aq in the created archive from that data. See section \fIReading from
  45. stdin\fP below for details.
  46. .sp
  47. The archive will consume almost no disk space for files or parts of files that
  48. have already been stored in other archives.
  49. .sp
  50. The archive name needs to be unique. It must not end in \(aq.checkpoint\(aq or
  51. \(aq.checkpoint.N\(aq (with N being a number), because these names are used for
  52. checkpoints and treated in special ways.
  53. .sp
  54. In the archive name, you may use the following placeholders:
  55. {now}, {utcnow}, {fqdn}, {hostname}, {user} and some others.
  56. .sp
  57. Backup speed is increased by not reprocessing files that are already part of
  58. existing archives and weren\(aqt modified. The detection of unmodified files is
  59. done by comparing multiple file metadata values with previous values kept in
  60. the files cache.
  61. .sp
  62. This comparison can operate in different modes as given by \fB\-\-files\-cache\fP:
  63. .INDENT 0.0
  64. .IP \(bu 2
  65. ctime,size,inode (default)
  66. .IP \(bu 2
  67. mtime,size,inode (default behaviour of borg versions older than 1.1.0rc4)
  68. .IP \(bu 2
  69. ctime,size (ignore the inode number)
  70. .IP \(bu 2
  71. mtime,size (ignore the inode number)
  72. .IP \(bu 2
  73. rechunk,ctime (all files are considered modified \- rechunk, cache ctime)
  74. .IP \(bu 2
  75. rechunk,mtime (all files are considered modified \- rechunk, cache mtime)
  76. .IP \(bu 2
  77. disabled (disable the files cache, all files considered modified \- rechunk)
  78. .UNINDENT
  79. .sp
  80. inode number: better safety, but often unstable on network filesystems
  81. .sp
  82. Normally, detecting file modifications will take inode information into
  83. consideration to improve the reliability of file change detection.
  84. This is problematic for files located on sshfs and similar network file
  85. systems which do not provide stable inode numbers, such files will always
  86. be considered modified. You can use modes without \fIinode\fP in this case to
  87. improve performance, but reliability of change detection might be reduced.
  88. .sp
  89. ctime vs. mtime: safety vs. speed
  90. .INDENT 0.0
  91. .IP \(bu 2
  92. ctime is a rather safe way to detect changes to a file (metadata and contents)
  93. as it can not be set from userspace. But, a metadata\-only change will already
  94. update the ctime, so there might be some unnecessary chunking/hashing even
  95. without content changes. Some filesystems do not support ctime (change time).
  96. E.g. doing a chown or chmod to a file will change its ctime.
  97. .IP \(bu 2
  98. mtime usually works and only updates if file contents were changed. But mtime
  99. can be arbitrarily set from userspace, e.g. to set mtime back to the same value
  100. it had before a content change happened. This can be used maliciously as well as
  101. well\-meant, but in both cases mtime based cache modes can be problematic.
  102. .UNINDENT
  103. .sp
  104. The mount points of filesystems or filesystem snapshots should be the same for every
  105. creation of a new archive to ensure fast operation. This is because the file cache that
  106. is used to determine changed files quickly uses absolute filenames.
  107. If this is not possible, consider creating a bind mount to a stable location.
  108. .sp
  109. The \fB\-\-progress\fP option shows (from left to right) Original, Compressed and Deduplicated
  110. (O, C and D, respectively), then the Number of files (N) processed so far, followed by
  111. the currently processed path.
  112. .sp
  113. When using \fB\-\-stats\fP, you will get some statistics about how much data was
  114. added \- the "This Archive" deduplicated size there is most interesting as that is
  115. how much your repository will grow. Please note that the "All archives" stats refer to
  116. the state after creation. Also, the \fB\-\-stats\fP and \fB\-\-dry\-run\fP options are mutually
  117. exclusive because the data is not actually compressed and deduplicated during a dry run.
  118. .sp
  119. See the output of the "borg help patterns" command for more help on exclude patterns.
  120. See the output of the "borg help placeholders" command for more help on placeholders.
  121. .SH OPTIONS
  122. .sp
  123. See \fIborg\-common(1)\fP for common options of Borg commands.
  124. .SS arguments
  125. .INDENT 0.0
  126. .TP
  127. .B ARCHIVE
  128. name of archive to create (must be also a valid directory name)
  129. .TP
  130. .B PATH
  131. paths to archive
  132. .UNINDENT
  133. .SS optional arguments
  134. .INDENT 0.0
  135. .TP
  136. .B \-n\fP,\fB \-\-dry\-run
  137. do not create a backup archive
  138. .TP
  139. .B \-s\fP,\fB \-\-stats
  140. print statistics for the created archive
  141. .TP
  142. .B \-\-list
  143. output verbose list of items (files, dirs, ...)
  144. .TP
  145. .BI \-\-filter \ STATUSCHARS
  146. only display items with the given status characters (see description)
  147. .TP
  148. .B \-\-json
  149. output stats as JSON. Implies \fB\-\-stats\fP\&.
  150. .TP
  151. .B \-\-no\-cache\-sync
  152. experimental: do not synchronize the cache. Implies not using the files cache.
  153. .TP
  154. .B \-\-no\-files\-cache
  155. do not load/update the file metadata cache used to detect unchanged files
  156. .TP
  157. .BI \-\-stdin\-name \ NAME
  158. use NAME in archive for stdin data (default: "stdin")
  159. .UNINDENT
  160. .SS Exclusion options
  161. .INDENT 0.0
  162. .TP
  163. .BI \-e \ PATTERN\fR,\fB \ \-\-exclude \ PATTERN
  164. exclude paths matching PATTERN
  165. .TP
  166. .BI \-\-exclude\-from \ EXCLUDEFILE
  167. read exclude patterns from EXCLUDEFILE, one per line
  168. .TP
  169. .BI \-\-pattern \ PATTERN
  170. experimental: include/exclude paths matching PATTERN
  171. .TP
  172. .BI \-\-patterns\-from \ PATTERNFILE
  173. experimental: read include/exclude patterns from PATTERNFILE, one per line
  174. .TP
  175. .B \-\-exclude\-caches
  176. exclude directories that contain a CACHEDIR.TAG file (\fI\%http://www.bford.info/cachedir/spec.html\fP)
  177. .TP
  178. .BI \-\-exclude\-if\-present \ NAME
  179. exclude directories that are tagged by containing a filesystem object with the given NAME
  180. .TP
  181. .B \-\-keep\-exclude\-tags\fP,\fB \-\-keep\-tag\-files
  182. if tag objects are specified with \fB\-\-exclude\-if\-present\fP, don\(aqt omit the tag objects themselves from the backup archive
  183. .TP
  184. .B \-\-exclude\-nodump
  185. exclude files flagged NODUMP
  186. .UNINDENT
  187. .SS Filesystem options
  188. .INDENT 0.0
  189. .TP
  190. .B \-x\fP,\fB \-\-one\-file\-system
  191. stay in the same file system and do not store mount points of other file systems
  192. .TP
  193. .B \-\-numeric\-owner
  194. only store numeric user and group identifiers
  195. .TP
  196. .B \-\-noatime
  197. do not store atime into archive
  198. .TP
  199. .B \-\-noctime
  200. do not store ctime into archive
  201. .TP
  202. .B \-\-nobirthtime
  203. do not store birthtime (creation date) into archive
  204. .TP
  205. .B \-\-nobsdflags
  206. do not read and store bsdflags (e.g. NODUMP, IMMUTABLE) into archive
  207. .TP
  208. .B \-\-ignore\-inode
  209. ignore inode data in the file metadata cache used to detect unchanged files.
  210. .TP
  211. .BI \-\-files\-cache \ MODE
  212. operate files cache in MODE. default: ctime,size,inode
  213. .TP
  214. .B \-\-read\-special
  215. 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.
  216. .UNINDENT
  217. .SS Archive options
  218. .INDENT 0.0
  219. .TP
  220. .BI \-\-comment \ COMMENT
  221. add a comment text to the archive
  222. .TP
  223. .BI \-\-timestamp \ TIMESTAMP
  224. manually specify the archive creation date/time (UTC, yyyy\-mm\-ddThh:mm:ss format). Alternatively, give a reference file/directory.
  225. .TP
  226. .BI \-c \ SECONDS\fR,\fB \ \-\-checkpoint\-interval \ SECONDS
  227. write checkpoint every SECONDS seconds (Default: 1800)
  228. .TP
  229. .BI \-\-chunker\-params \ PARAMS
  230. specify the chunker parameters (CHUNK_MIN_EXP, CHUNK_MAX_EXP, HASH_MASK_BITS, HASH_WINDOW_SIZE). default: 19,23,21,4095
  231. .TP
  232. .BI \-C \ COMPRESSION\fR,\fB \ \-\-compression \ COMPRESSION
  233. select compression algorithm, see the output of the "borg help compression" command for details.
  234. .UNINDENT
  235. .SH EXAMPLES
  236. .INDENT 0.0
  237. .INDENT 3.5
  238. .sp
  239. .nf
  240. .ft C
  241. # Backup ~/Documents into an archive named "my\-documents"
  242. $ borg create /path/to/repo::my\-documents ~/Documents
  243. # same, but list all files as we process them
  244. $ borg create \-\-list /path/to/repo::my\-documents ~/Documents
  245. # Backup ~/Documents and ~/src but exclude pyc files
  246. $ borg create /path/to/repo::my\-files \e
  247. ~/Documents \e
  248. ~/src \e
  249. \-\-exclude \(aq*.pyc\(aq
  250. # Backup home directories excluding image thumbnails (i.e. only
  251. # /home/<one directory>/.thumbnails is excluded, not /home/*/*/.thumbnails etc.)
  252. $ borg create /path/to/repo::my\-files /home \e
  253. \-\-exclude \(aqsh:/home/*/.thumbnails\(aq
  254. # Backup the root filesystem into an archive named "root\-YYYY\-MM\-DD"
  255. # use zlib compression (good, but slow) \- default is lz4 (fast, low compression ratio)
  256. $ borg create \-C zlib,6 \-\-one\-file\-system /path/to/repo::root\-{now:%Y\-%m\-%d} /
  257. # Backup a remote host locally ("pull" style) using sshfs
  258. $ mkdir sshfs\-mount
  259. $ sshfs root@example.com:/ sshfs\-mount
  260. $ cd sshfs\-mount
  261. $ borg create /path/to/repo::example.com\-root\-{now:%Y\-%m\-%d} .
  262. $ cd ..
  263. $ fusermount \-u sshfs\-mount
  264. # Make a big effort in fine granular deduplication (big chunk management
  265. # overhead, needs a lot of RAM and disk space, see formula in internals
  266. # docs \- same parameters as borg < 1.0 or attic):
  267. $ borg create \-\-chunker\-params 10,23,16,4095 /path/to/repo::small /smallstuff
  268. # Backup a raw device (must not be active/in use/mounted at that time)
  269. $ dd if=/dev/sdx bs=10M | borg create /path/to/repo::my\-sdx \-
  270. # No compression (none)
  271. $ borg create \-\-compression none /path/to/repo::arch ~
  272. # Super fast, low compression (lz4, default)
  273. $ borg create /path/to/repo::arch ~
  274. # Less fast, higher compression (zlib, N = 0..9)
  275. $ borg create \-\-compression zlib,N /path/to/repo::arch ~
  276. # Even slower, even higher compression (lzma, N = 0..9)
  277. $ borg create \-\-compression lzma,N /path/to/repo::arch ~
  278. # Only compress compressible data with lzma,N (N = 0..9)
  279. $ borg create \-\-compression auto,lzma,N /path/to/repo::arch ~
  280. # Use short hostname, user name and current time in archive name
  281. $ borg create /path/to/repo::{hostname}\-{user}\-{now} ~
  282. # Similar, use the same datetime format that is default as of borg 1.1
  283. $ borg create /path/to/repo::{hostname}\-{user}\-{now:%Y\-%m\-%dT%H:%M:%S} ~
  284. # As above, but add nanoseconds
  285. $ borg create /path/to/repo::{hostname}\-{user}\-{now:%Y\-%m\-%dT%H:%M:%S.%f} ~
  286. # Backing up relative paths by moving into the correct directory first
  287. $ cd /home/user/Documents
  288. # The root directory of the archive will be "projectA"
  289. $ borg create /path/to/repo::daily\-projectA\-{now:%Y\-%m\-%d} projectA
  290. .ft P
  291. .fi
  292. .UNINDENT
  293. .UNINDENT
  294. .SH NOTES
  295. .sp
  296. The \fB\-\-exclude\fP patterns are not like tar. In tar \fB\-\-exclude\fP .bundler/gems will
  297. exclude foo/.bundler/gems. In borg it will not, you need to use \fB\-\-exclude\fP
  298. \(aq*/.bundler/gems\(aq to get the same effect. See \fBborg help patterns\fP for
  299. more information.
  300. .sp
  301. In addition to using \fB\-\-exclude\fP patterns, it is possible to use
  302. \fB\-\-exclude\-if\-present\fP to specify the name of a filesystem object (e.g. a file
  303. or folder name) which, when contained within another folder, will prevent the
  304. containing folder from being backed up. By default, the containing folder and
  305. all of its contents will be omitted from the backup. If, however, you wish to
  306. only include the objects specified by \fB\-\-exclude\-if\-present\fP in your backup,
  307. and not include any other contents of the containing folder, this can be enabled
  308. through using the \fB\-\-keep\-exclude\-tags\fP option.
  309. .SS Item flags
  310. .sp
  311. \fB\-\-list\fP outputs a list of all files, directories and other
  312. file system items it considered (no matter whether they had content changes
  313. or not). For each item, it prefixes a single\-letter flag that indicates type
  314. and/or status of the item.
  315. .sp
  316. If you are interested only in a subset of that output, you can give e.g.
  317. \fB\-\-filter=AME\fP and it will only show regular files with A, M or E status (see
  318. below).
  319. .sp
  320. A uppercase character represents the status of a regular file relative to the
  321. "files" cache (not relative to the repo \-\- this is an issue if the files cache
  322. is not used). Metadata is stored in any case and for \(aqA\(aq and \(aqM\(aq also new data
  323. chunks are stored. For \(aqU\(aq all data chunks refer to already existing chunks.
  324. .INDENT 0.0
  325. .IP \(bu 2
  326. \(aqA\(aq = regular file, added (see also \fIa_status_oddity\fP in the FAQ)
  327. .IP \(bu 2
  328. \(aqM\(aq = regular file, modified
  329. .IP \(bu 2
  330. \(aqU\(aq = regular file, unchanged
  331. .IP \(bu 2
  332. \(aqE\(aq = regular file, an error happened while accessing/reading \fIthis\fP file
  333. .UNINDENT
  334. .sp
  335. A lowercase character means a file type other than a regular file,
  336. borg usually just stores their metadata:
  337. .INDENT 0.0
  338. .IP \(bu 2
  339. \(aqd\(aq = directory
  340. .IP \(bu 2
  341. \(aqb\(aq = block device
  342. .IP \(bu 2
  343. \(aqc\(aq = char device
  344. .IP \(bu 2
  345. \(aqh\(aq = regular file, hardlink (to already seen inodes)
  346. .IP \(bu 2
  347. \(aqs\(aq = symlink
  348. .IP \(bu 2
  349. \(aqf\(aq = fifo
  350. .UNINDENT
  351. .sp
  352. Other flags used include:
  353. .INDENT 0.0
  354. .IP \(bu 2
  355. \(aqi\(aq = backup data was read from standard input (stdin)
  356. .IP \(bu 2
  357. \(aq\-\(aq = dry run, item was \fInot\fP backed up
  358. .IP \(bu 2
  359. \(aqx\(aq = excluded, item was \fInot\fP backed up
  360. .IP \(bu 2
  361. \(aq?\(aq = missing status code (if you see this, please file a bug report!)
  362. .UNINDENT
  363. .SS Reading from stdin
  364. .sp
  365. To read from stdin, specify \fB\-\fP as path and pipe directly to borg:
  366. .INDENT 0.0
  367. .INDENT 3.5
  368. .sp
  369. .nf
  370. .ft C
  371. backup\-vm \-\-id myvm \-\-stdout | borg create REPO::ARCHIVE \-
  372. .ft P
  373. .fi
  374. .UNINDENT
  375. .UNINDENT
  376. .sp
  377. Note that piping to borg creates an archive even if the command piping
  378. to borg exits with a failure. In this case, \fBone can end up with
  379. truncated output being backed up\fP\&.
  380. .sp
  381. Reading from stdin yields just a stream of data without file metadata
  382. associated with it, and the files cache is not needed at all. So it is
  383. safe to disable it via \fB\-\-no\-files\-cache\fP and speed up backup
  384. creation a bit.
  385. .sp
  386. By default, the content read from stdin is stored in a file called \(aqstdin\(aq.
  387. Use \fB\-\-stdin\-name\fP to change the name.
  388. .SH SEE ALSO
  389. .sp
  390. \fIborg\-common(1)\fP, \fIborg\-delete(1)\fP, \fIborg\-prune(1)\fP, \fIborg\-check(1)\fP, \fIborg\-patterns(1)\fP, \fIborg\-placeholders(1)\fP, \fIborg\-compression(1)\fP
  391. .SH AUTHOR
  392. The Borg Collective
  393. .\" Generated by docutils manpage writer.
  394. .