borg-patterns.1 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH BORG-PATTERNS 1 "2017-02-11" "" "borg backup tool"
  4. .SH NAME
  5. borg-patterns \- Details regarding patterns
  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 DESCRIPTION
  34. .sp
  35. Exclusion patterns support four separate styles, fnmatch, shell, regular
  36. expressions and path prefixes. By default, fnmatch is used. If followed
  37. by a colon (\(aq:\(aq) the first two characters of a pattern are used as a
  38. style selector. Explicit style selection is necessary when a
  39. non\-default style is desired or when the desired pattern starts with
  40. two alphanumeric characters followed by a colon (i.e. \fIaa:something/*\fP).
  41. .sp
  42. \fI\%Fnmatch\fP, selector \fIfm:\fP
  43. .INDENT 0.0
  44. .INDENT 3.5
  45. This is the default style. These patterns use a variant of shell
  46. pattern syntax, with \(aq*\(aq matching any number of characters, \(aq?\(aq
  47. matching any single character, \(aq[...]\(aq matching any single
  48. character specified, including ranges, and \(aq[!...]\(aq matching any
  49. character not specified. For the purpose of these patterns, the
  50. path separator (\(aq\(aq for Windows and \(aq/\(aq on other systems) is not
  51. treated specially. Wrap meta\-characters in brackets for a literal
  52. match (i.e. \fI[?]\fP to match the literal character \fI?\fP). For a path
  53. to match a pattern, it must completely match from start to end, or
  54. must match from the start to just before a path separator. Except
  55. for the root path, paths will never end in the path separator when
  56. matching is attempted. Thus, if a given pattern ends in a path
  57. separator, a \(aq*\(aq is appended before matching is attempted.
  58. .UNINDENT
  59. .UNINDENT
  60. .sp
  61. Shell\-style patterns, selector \fIsh:\fP
  62. .INDENT 0.0
  63. .INDENT 3.5
  64. Like fnmatch patterns these are similar to shell patterns. The difference
  65. is that the pattern may include \fI**/\fP for matching zero or more directory
  66. levels, \fI*\fP for matching zero or more arbitrary characters with the
  67. exception of any path separator.
  68. .UNINDENT
  69. .UNINDENT
  70. .sp
  71. Regular expressions, selector \fIre:\fP
  72. .INDENT 0.0
  73. .INDENT 3.5
  74. Regular expressions similar to those found in Perl are supported. Unlike
  75. shell patterns regular expressions are not required to match the complete
  76. path and any substring match is sufficient. It is strongly recommended to
  77. anchor patterns to the start (\(aq^\(aq), to the end (\(aq$\(aq) or both. Path
  78. separators (\(aq\(aq for Windows and \(aq/\(aq on other systems) in paths are
  79. always normalized to a forward slash (\(aq/\(aq) before applying a pattern. The
  80. regular expression syntax is described in the \fI\%Python documentation for
  81. the re module\fP\&.
  82. .UNINDENT
  83. .UNINDENT
  84. .sp
  85. Prefix path, selector \fIpp:\fP
  86. .INDENT 0.0
  87. .INDENT 3.5
  88. This pattern style is useful to match whole sub\-directories. The pattern
  89. \fIpp:/data/bar\fP matches \fI/data/bar\fP and everything therein.
  90. .UNINDENT
  91. .UNINDENT
  92. .sp
  93. Exclusions can be passed via the command line option \fI\-\-exclude\fP\&. When used
  94. from within a shell the patterns should be quoted to protect them from
  95. expansion.
  96. .sp
  97. The \fI\-\-exclude\-from\fP option permits loading exclusion patterns from a text
  98. file with one pattern per line. Lines empty or starting with the number sign
  99. (\(aq#\(aq) after removing whitespace on both ends are ignored. The optional style
  100. selector prefix is also supported for patterns loaded from a file. Due to
  101. whitespace removal paths with whitespace at the beginning or end can only be
  102. excluded using regular expressions.
  103. .sp
  104. Examples:
  105. .INDENT 0.0
  106. .INDENT 3.5
  107. .sp
  108. .nf
  109. .ft C
  110. # Exclude \(aq/home/user/file.o\(aq but not \(aq/home/user/file.odt\(aq:
  111. $ borg create \-e \(aq*.o\(aq backup /
  112. # Exclude \(aq/home/user/junk\(aq and \(aq/home/user/subdir/junk\(aq but
  113. # not \(aq/home/user/importantjunk\(aq or \(aq/etc/junk\(aq:
  114. $ borg create \-e \(aq/home/*/junk\(aq backup /
  115. # Exclude the contents of \(aq/home/user/cache\(aq but not the directory itself:
  116. $ borg create \-e /home/user/cache/ backup /
  117. # The file \(aq/home/user/cache/important\(aq is *not* backed up:
  118. $ borg create \-e /home/user/cache/ backup / /home/user/cache/important
  119. # The contents of directories in \(aq/home\(aq are not backed up when their name
  120. # ends in \(aq.tmp\(aq
  121. $ borg create \-\-exclude \(aqre:^/home/[^/]+\e.tmp/\(aq backup /
  122. # Load exclusions from file
  123. $ cat >exclude.txt <<EOF
  124. # Comment line
  125. /home/*/junk
  126. *.tmp
  127. fm:aa:something/*
  128. re:^/home/[^/]\e.tmp/
  129. sh:/home/*/.thumbnails
  130. EOF
  131. $ borg create \-\-exclude\-from exclude.txt backup /
  132. .ft P
  133. .fi
  134. .UNINDENT
  135. .UNINDENT
  136. .SH AUTHOR
  137. The Borg Collective
  138. .\" Generated by docutils manpage writer.
  139. .