help.rst.inc 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. Exclusion patterns support four separate styles, fnmatch, shell, regular
  6. expressions and path prefixes. By default, fnmatch is used. If followed
  7. by a colon (':') the first two characters of a pattern are used as a
  8. style selector. Explicit style selection is necessary when a
  9. non-default style is desired or when the desired pattern starts with
  10. two alphanumeric characters followed by a colon (i.e. `aa:something/*`).
  11. `Fnmatch <https://docs.python.org/3/library/fnmatch.html>`_, selector `fm:`
  12. This is the default style. These patterns use a variant of shell
  13. pattern syntax, with '*' matching any number of characters, '?'
  14. matching any single character, '[...]' matching any single
  15. character specified, including ranges, and '[!...]' matching any
  16. character not specified. For the purpose of these patterns, the
  17. path separator ('\' for Windows and '/' on other systems) is not
  18. treated specially. Wrap meta-characters in brackets for a literal
  19. match (i.e. `[?]` to match the literal character `?`). For a path
  20. to match a pattern, it must completely match from start to end, or
  21. must match from the start to just before a path separator. Except
  22. for the root path, paths will never end in the path separator when
  23. matching is attempted. Thus, if a given pattern ends in a path
  24. separator, a '*' is appended before matching is attempted.
  25. Shell-style patterns, selector `sh:`
  26. Like fnmatch patterns these are similar to shell patterns. The difference
  27. is that the pattern may include `**/` for matching zero or more directory
  28. levels, `*` for matching zero or more arbitrary characters with the
  29. exception of any path separator.
  30. Regular expressions, selector `re:`
  31. Regular expressions similar to those found in Perl are supported. Unlike
  32. shell patterns regular expressions are not required to match the complete
  33. path and any substring match is sufficient. It is strongly recommended to
  34. anchor patterns to the start ('^'), to the end ('$') or both. Path
  35. separators ('\' for Windows and '/' on other systems) in paths are
  36. always normalized to a forward slash ('/') before applying a pattern. The
  37. regular expression syntax is described in the `Python documentation for
  38. the re module <https://docs.python.org/3/library/re.html>`_.
  39. Prefix path, selector `pp:`
  40. This pattern style is useful to match whole sub-directories. The pattern
  41. `pp:/data/bar` matches `/data/bar` and everything therein.
  42. Exclusions can be passed via the command line option `--exclude`. When used
  43. from within a shell the patterns should be quoted to protect them from
  44. expansion.
  45. The `--exclude-from` option permits loading exclusion patterns from a text
  46. file with one pattern per line. Lines empty or starting with the number sign
  47. ('#') after removing whitespace on both ends are ignored. The optional style
  48. selector prefix is also supported for patterns loaded from a file. Due to
  49. whitespace removal paths with whitespace at the beginning or end can only be
  50. excluded using regular expressions.
  51. Examples::
  52. # Exclude '/home/user/file.o' but not '/home/user/file.odt':
  53. $ borg create -e '*.o' backup /
  54. # Exclude '/home/user/junk' and '/home/user/subdir/junk' but
  55. # not '/home/user/importantjunk' or '/etc/junk':
  56. $ borg create -e '/home/*/junk' backup /
  57. # Exclude the contents of '/home/user/cache' but not the directory itself:
  58. $ borg create -e /home/user/cache/ backup /
  59. # The file '/home/user/cache/important' is *not* backed up:
  60. $ borg create -e /home/user/cache/ backup / /home/user/cache/important
  61. # The contents of directories in '/home' are not backed up when their name
  62. # ends in '.tmp'
  63. $ borg create --exclude 're:^/home/[^/]+\.tmp/' backup /
  64. # Load exclusions from file
  65. $ cat >exclude.txt <<EOF
  66. # Comment line
  67. /home/*/junk
  68. *.tmp
  69. fm:aa:something/*
  70. re:^/home/[^/]\.tmp/
  71. sh:/home/*/.thumbnails
  72. EOF
  73. $ borg create --exclude-from exclude.txt backup /
  74. .. _borg_placeholders:
  75. borg help placeholders
  76. ~~~~~~~~~~~~~~~~~~~~~~
  77. Repository (or Archive) URLs, --prefix and --remote-path values support these
  78. placeholders:
  79. {hostname}
  80. The (short) hostname of the machine.
  81. {fqdn}
  82. The full name of the machine.
  83. {now}
  84. The current local date and time, by default in ISO-8601 format.
  85. 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}
  86. {utcnow}
  87. The current UTC date and time, by default in ISO-8601 format.
  88. 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}
  89. {user}
  90. The user name (or UID, if no name is available) of the user running borg.
  91. {pid}
  92. The current process ID.
  93. {borgversion}
  94. The version of borg, e.g.: 1.0.8rc1
  95. {borgmajor}
  96. The version of borg, only the major version, e.g.: 1
  97. {borgminor}
  98. The version of borg, only major and minor version, e.g.: 1.0
  99. {borgpatch}
  100. The version of borg, only major, minor and patch version, e.g.: 1.0.8
  101. Examples::
  102. borg create /path/to/repo::{hostname}-{user}-{utcnow} ...
  103. borg create /path/to/repo::{hostname}-{now:%Y-%m-%d_%H:%M:%S} ...
  104. borg prune --prefix '{hostname}-' ...
  105. .. _borg_compression:
  106. borg help compression
  107. ~~~~~~~~~~~~~~~~~~~~~
  108. Compression is off by default, if you want some, you have to specify what you want.
  109. Valid compression specifiers are:
  110. none
  111. Do not compress. (default)
  112. lz4
  113. Use lz4 compression. High speed, low compression.
  114. zlib[,L]
  115. Use zlib ("gz") compression. Medium speed, medium compression.
  116. If you do not explicitely give the compression level L (ranging from 0
  117. to 9), it will use level 6.
  118. Giving level 0 (means "no compression", but still has zlib protocol
  119. overhead) is usually pointless, you better use "none" compression.
  120. lzma[,L]
  121. Use lzma ("xz") compression. Low speed, high compression.
  122. If you do not explicitely give the compression level L (ranging from 0
  123. to 9), it will use level 6.
  124. Giving levels above 6 is pointless and counterproductive because it does
  125. not compress better due to the buffer size used by borg - but it wastes
  126. lots of CPU cycles and RAM.
  127. auto,C[,L]
  128. Use a built-in heuristic to decide per chunk whether to compress or not.
  129. The heuristic tries with lz4 whether the data is compressible.
  130. For incompressible data, it will not use compression (uses "none").
  131. For compressible data, it uses the given C[,L] compression - with C[,L]
  132. being any valid compression specifier.
  133. The decision about which compression to use is done by borg like this:
  134. 1. find a compression specifier (per file):
  135. match the path/filename against all patterns in all --compression-from
  136. files (if any). If a pattern matches, use the compression spec given for
  137. that pattern. If no pattern matches (and also if you do not give any
  138. --compression-from option), default to the compression spec given by
  139. --compression. See docs/misc/compression.conf for an example config.
  140. 2. if the found compression spec is not "auto", the decision is taken:
  141. use the found compression spec.
  142. 3. if the found compression spec is "auto", test compressibility of each
  143. chunk using lz4.
  144. If it is compressible, use the C,[L] compression spec given within the
  145. "auto" specifier. If it is not compressible, use no compression.
  146. Examples::
  147. borg create --compression lz4 REPO::ARCHIVE data
  148. borg create --compression zlib REPO::ARCHIVE data
  149. borg create --compression zlib,1 REPO::ARCHIVE data
  150. borg create --compression auto,lzma,6 REPO::ARCHIVE data
  151. borg create --compression-from compression.conf --compression auto,lzma ...
  152. compression.conf has entries like::
  153. # example config file for --compression-from option
  154. #
  155. # Format of non-comment / non-empty lines:
  156. # <compression-spec>:<path/filename pattern>
  157. # compression-spec is same format as for --compression option
  158. # path/filename pattern is same format as for --exclude option
  159. none:*.gz
  160. none:*.zip
  161. none:*.mp3
  162. none:*.ogg
  163. General remarks:
  164. It is no problem to mix different compression methods in one repo,
  165. deduplication is done on the source data chunks (not on the compressed
  166. or encrypted data).
  167. If some specific chunk was once compressed and stored into the repo, creating
  168. another backup that also uses this chunk will not change the stored chunk.
  169. So if you use different compression specs for the backups, whichever stores a
  170. chunk first determines its compression. See also borg recreate.