help.rst.inc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. .. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!
  2. .. _borg_patterns:
  3. borg help patterns
  4. ~~~~~~~~~~~~~~~~~~
  5. File patterns support these styles: fnmatch, shell, regular expressions,
  6. path prefixes and path full-matches. By default, fnmatch is used for
  7. `--exclude` patterns and shell-style is used for the experimental `--pattern`
  8. option.
  9. If followed by a colon (':') the first two characters of a pattern are used as a
  10. style selector. Explicit style selection is necessary when a
  11. non-default style is desired or when the desired pattern starts with
  12. two alphanumeric characters followed by a colon (i.e. `aa:something/*`).
  13. `Fnmatch <https://docs.python.org/3/library/fnmatch.html>`_, selector `fm:`
  14. This is the default style for --exclude and --exclude-from.
  15. These patterns use a variant of shell pattern syntax, with '\*' matching
  16. any number of characters, '?' matching any single character, '[...]'
  17. matching any single character specified, including ranges, and '[!...]'
  18. matching any character not specified. For the purpose of these patterns,
  19. the path separator ('\' for Windows and '/' on other systems) is not
  20. treated specially. Wrap meta-characters in brackets for a literal
  21. match (i.e. `[?]` to match the literal character `?`). For a path
  22. to match a pattern, it must completely match from start to end, or
  23. must match from the start to just before a path separator. Except
  24. for the root path, paths will never end in the path separator when
  25. matching is attempted. Thus, if a given pattern ends in a path
  26. separator, a '*' is appended before matching is attempted.
  27. Shell-style patterns, selector `sh:`
  28. This is the default style for --pattern and --patterns-from.
  29. Like fnmatch patterns these are similar to shell patterns. The difference
  30. is that the pattern may include `**/` for matching zero or more directory
  31. levels, `*` for matching zero or more arbitrary characters with the
  32. exception of any path separator.
  33. Regular expressions, selector `re:`
  34. Regular expressions similar to those found in Perl are supported. Unlike
  35. shell patterns regular expressions are not required to match the complete
  36. path and any substring match is sufficient. It is strongly recommended to
  37. anchor patterns to the start ('^'), to the end ('$') or both. Path
  38. separators ('\' for Windows and '/' on other systems) in paths are
  39. always normalized to a forward slash ('/') before applying a pattern. The
  40. regular expression syntax is described in the `Python documentation for
  41. the re module <https://docs.python.org/3/library/re.html>`_.
  42. Path prefix, selector `pp:`
  43. This pattern style is useful to match whole sub-directories. The pattern
  44. `pp:/data/bar` matches `/data/bar` and everything therein.
  45. Path full-match, selector `pf:`
  46. This pattern style is useful to match whole paths.
  47. This is kind of a pseudo pattern as it can not have any variable or
  48. unspecified parts - the full, precise path must be given.
  49. `pf:/data/foo.txt` matches `/data/foo.txt` only.
  50. Implementation note: this is implemented via very time-efficient O(1)
  51. hashtable lookups (this means you can have huge amounts of such patterns
  52. without impacting performance much).
  53. Due to that, this kind of pattern does not respect any context or order.
  54. If you use such a pattern to include a file, it will always be included
  55. (if the directory recursion encounters it).
  56. Other include/exclude patterns that would normally match will be ignored.
  57. Same logic applies for exclude.
  58. Exclusions can be passed via the command line option `--exclude`. When used
  59. from within a shell the patterns should be quoted to protect them from
  60. expansion.
  61. The `--exclude-from` option permits loading exclusion patterns from a text
  62. file with one pattern per line. Lines empty or starting with the number sign
  63. ('#') after removing whitespace on both ends are ignored. The optional style
  64. selector prefix is also supported for patterns loaded from a file. Due to
  65. whitespace removal paths with whitespace at the beginning or end can only be
  66. excluded using regular expressions.
  67. Examples::
  68. # Exclude '/home/user/file.o' but not '/home/user/file.odt':
  69. $ borg create -e '*.o' backup /
  70. # Exclude '/home/user/junk' and '/home/user/subdir/junk' but
  71. # not '/home/user/importantjunk' or '/etc/junk':
  72. $ borg create -e '/home/*/junk' backup /
  73. # Exclude the contents of '/home/user/cache' but not the directory itself:
  74. $ borg create -e /home/user/cache/ backup /
  75. # The file '/home/user/cache/important' is *not* backed up:
  76. $ borg create -e /home/user/cache/ backup / /home/user/cache/important
  77. # The contents of directories in '/home' are not backed up when their name
  78. # ends in '.tmp'
  79. $ borg create --exclude 're:^/home/[^/]+\.tmp/' backup /
  80. # Load exclusions from file
  81. $ cat >exclude.txt <<EOF
  82. # Comment line
  83. /home/*/junk
  84. *.tmp
  85. fm:aa:something/*
  86. re:^/home/[^/]\.tmp/
  87. sh:/home/*/.thumbnails
  88. EOF
  89. $ borg create --exclude-from exclude.txt backup /
  90. A more general and easier to use way to define filename matching patterns exists
  91. with the `--pattern` and `--patterns-from` options. Using these, you may specify
  92. the backup roots (starting points) and patterns for inclusion/exclusion. A
  93. root path starts with the prefix `R`, followed by a path (a plain path, not a
  94. file pattern). An include rule starts with the prefix +, an exclude rule starts
  95. with the prefix -, both followed by a pattern.
  96. Inclusion patterns are useful to include paths that are contained in an excluded
  97. path. The first matching pattern is used so if an include pattern matches before
  98. an exclude pattern, the file is backed up.
  99. Note that the default pattern style for `--pattern` and `--patterns-from` is
  100. shell style (`sh:`), so those patterns behave similar to rsync include/exclude
  101. patterns. The pattern style can be set via the `P` prefix.
  102. Patterns (`--pattern`) and excludes (`--exclude`) from the command line are
  103. considered first (in the order of appearance). Then patterns from `--patterns-from`
  104. are added. Exclusion patterns from `--exclude-from` files are appended last.
  105. An example `--patterns-from` file could look like that::
  106. # "sh:" pattern style is the default, so the following line is not needed:
  107. P sh
  108. R /
  109. # can be rebuild
  110. - /home/*/.cache
  111. # they're downloads for a reason
  112. - /home/*/Downloads
  113. # susan is a nice person
  114. # include susans home
  115. + /home/susan
  116. # don't backup the other home directories
  117. - /home/*
  118. .. _borg_placeholders:
  119. borg help placeholders
  120. ~~~~~~~~~~~~~~~~~~~~~~
  121. Repository (or Archive) URLs, --prefix and --remote-path values support these
  122. placeholders:
  123. {hostname}
  124. The (short) hostname of the machine.
  125. {fqdn}
  126. The full name of the machine.
  127. {now}
  128. The current local date and time, by default in ISO-8601 format.
  129. You can also supply your own `format string <https://docs.python.org/3.4/library/datetime.html#strftime-and-strptime-behavior>`_, e.g. {now:%Y-%m-%d_%H:%M:%S}
  130. {utcnow}
  131. The current UTC date and time, by default in ISO-8601 format.
  132. You can also supply your own `format string <https://docs.python.org/3.4/library/datetime.html#strftime-and-strptime-behavior>`_, e.g. {utcnow:%Y-%m-%d_%H:%M:%S}
  133. {user}
  134. The user name (or UID, if no name is available) of the user running borg.
  135. {pid}
  136. The current process ID.
  137. {borgversion}
  138. The version of borg, e.g.: 1.0.8rc1
  139. {borgmajor}
  140. The version of borg, only the major version, e.g.: 1
  141. {borgminor}
  142. The version of borg, only major and minor version, e.g.: 1.0
  143. {borgpatch}
  144. The version of borg, only major, minor and patch version, e.g.: 1.0.8
  145. If literal curly braces need to be used, double them for escaping::
  146. borg create /path/to/repo::{{literal_text}}
  147. Examples::
  148. borg create /path/to/repo::{hostname}-{user}-{utcnow} ...
  149. borg create /path/to/repo::{hostname}-{now:%Y-%m-%d_%H:%M:%S} ...
  150. borg prune --prefix '{hostname}-' ...
  151. .. note::
  152. systemd uses a difficult, non-standard syntax for command lines in unit files (refer to
  153. the `systemd.unit(5)` manual page).
  154. When invoking borg from unit files, pay particular attention to escaping,
  155. especially when using the now/utcnow placeholders, since systemd performs its own
  156. %-based variable replacement even in quoted text. To avoid interference from systemd,
  157. double all percent signs (``{hostname}-{now:%Y-%m-%d_%H:%M:%S}``
  158. becomes ``{hostname}-{now:%%Y-%%m-%%d_%%H:%%M:%%S}``).
  159. .. _borg_compression:
  160. borg help compression
  161. ~~~~~~~~~~~~~~~~~~~~~
  162. Compression is lz4 by default. If you want something else, you have to specify what you want.
  163. Valid compression specifiers are:
  164. none
  165. Do not compress.
  166. lz4
  167. Use lz4 compression. High speed, low compression. (default)
  168. zlib[,L]
  169. Use zlib ("gz") compression. Medium speed, medium compression.
  170. If you do not explicitely give the compression level L (ranging from 0
  171. to 9), it will use level 6.
  172. Giving level 0 (means "no compression", but still has zlib protocol
  173. overhead) is usually pointless, you better use "none" compression.
  174. lzma[,L]
  175. Use lzma ("xz") compression. Low speed, high compression.
  176. If you do not explicitely give the compression level L (ranging from 0
  177. to 9), it will use level 6.
  178. Giving levels above 6 is pointless and counterproductive because it does
  179. not compress better due to the buffer size used by borg - but it wastes
  180. lots of CPU cycles and RAM.
  181. auto,C[,L]
  182. Use a built-in heuristic to decide per chunk whether to compress or not.
  183. The heuristic tries with lz4 whether the data is compressible.
  184. For incompressible data, it will not use compression (uses "none").
  185. For compressible data, it uses the given C[,L] compression - with C[,L]
  186. being any valid compression specifier.
  187. Examples::
  188. borg create --compression lz4 REPO::ARCHIVE data
  189. borg create --compression zlib REPO::ARCHIVE data
  190. borg create --compression zlib,1 REPO::ARCHIVE data
  191. borg create --compression auto,lzma,6 REPO::ARCHIVE data
  192. borg create --compression auto,lzma ...
  193. General remarks:
  194. It is no problem to mix different compression methods in one repo,
  195. deduplication is done on the source data chunks (not on the compressed
  196. or encrypted data).
  197. If some specific chunk was once compressed and stored into the repo, creating
  198. another backup that also uses this chunk will not change the stored chunk.
  199. So if you use different compression specs for the backups, whichever stores a
  200. chunk first determines its compression. See also borg recreate.