help.rst.inc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. ::
  6. Exclusion patterns support four separate styles, fnmatch, shell, regular
  7. expressions and path prefixes. By default, fnmatch is used. If followed
  8. by a colon (':') the first two characters of a pattern are used as a
  9. style selector. Explicit style selection is necessary when a
  10. non-default style is desired or when the desired pattern starts with
  11. two alphanumeric characters followed by a colon (i.e. `aa:something/*`).
  12. `Fnmatch <https://docs.python.org/3/library/fnmatch.html>`_, selector `fm:`
  13. This is the default style. These patterns use a variant of shell
  14. pattern syntax, with '*' matching any number of characters, '?'
  15. matching any single character, '[...]' matching any single
  16. character specified, including ranges, and '[!...]' matching any
  17. character not specified. For the purpose of these patterns, the
  18. path separator ('\' for Windows and '/' on other systems) is not
  19. treated specially. Wrap meta-characters in brackets for a literal
  20. match (i.e. `[?]` to match the literal character `?`). For a path
  21. to match a pattern, it must completely match from start to end, or
  22. must match from the start to just before a path separator. Except
  23. for the root path, paths will never end in the path separator when
  24. matching is attempted. Thus, if a given pattern ends in a path
  25. separator, a '*' is appended before matching is attempted.
  26. Shell-style patterns, selector `sh:`
  27. Like fnmatch patterns these are similar to shell patterns. The difference
  28. is that the pattern may include `**/` for matching zero or more directory
  29. levels, `*` for matching zero or more arbitrary characters with the
  30. exception of any path separator.
  31. Regular expressions, selector `re:`
  32. Regular expressions similar to those found in Perl are supported. Unlike
  33. shell patterns regular expressions are not required to match the complete
  34. path and any substring match is sufficient. It is strongly recommended to
  35. anchor patterns to the start ('^'), to the end ('$') or both. Path
  36. separators ('\' for Windows and '/' on other systems) in paths are
  37. always normalized to a forward slash ('/') before applying a pattern. The
  38. regular expression syntax is described in the `Python documentation for
  39. the re module <https://docs.python.org/3/library/re.html>`_.
  40. Prefix path, selector `pp:`
  41. This pattern style is useful to match whole sub-directories. The pattern
  42. `pp:/data/bar` matches `/data/bar` and everything therein.
  43. Exclusions can be passed via the command line option `--exclude`. When used
  44. from within a shell the patterns should be quoted to protect them from
  45. expansion.
  46. The `--exclude-from` option permits loading exclusion patterns from a text
  47. file with one pattern per line. Lines empty or starting with the number sign
  48. ('#') after removing whitespace on both ends are ignored. The optional style
  49. selector prefix is also supported for patterns loaded from a file. Due to
  50. whitespace removal paths with whitespace at the beginning or end can only be
  51. excluded using regular expressions.
  52. Examples::
  53. # Exclude '/home/user/file.o' but not '/home/user/file.odt':
  54. $ borg create -e '*.o' backup /
  55. # Exclude '/home/user/junk' and '/home/user/subdir/junk' but
  56. # not '/home/user/importantjunk' or '/etc/junk':
  57. $ borg create -e '/home/*/junk' backup /
  58. # Exclude the contents of '/home/user/cache' but not the directory itself:
  59. $ borg create -e /home/user/cache/ backup /
  60. # The file '/home/user/cache/important' is *not* backed up:
  61. $ borg create -e /home/user/cache/ backup / /home/user/cache/important
  62. # The contents of directories in '/home' are not backed up when their name
  63. # ends in '.tmp'
  64. $ borg create --exclude 're:^/home/[^/]+\.tmp/' backup /
  65. # Load exclusions from file
  66. $ cat >exclude.txt <<EOF
  67. # Comment line
  68. /home/*/junk
  69. *.tmp
  70. fm:aa:something/*
  71. re:^/home/[^/]\.tmp/
  72. sh:/home/*/.thumbnails
  73. EOF
  74. $ borg create --exclude-from exclude.txt backup /
  75. .. _borg_placeholders:
  76. borg help placeholders
  77. ~~~~~~~~~~~~~~~~~~~~~~
  78. ::
  79. Repository (or Archive) URLs and --prefix values support these placeholders:
  80. {hostname}
  81. The (short) hostname of the machine.
  82. {fqdn}
  83. The full name of the machine.
  84. {now}
  85. The current local date and time.
  86. {utcnow}
  87. The current UTC date and time.
  88. {user}
  89. The user name (or UID, if no name is available) of the user running borg.
  90. {pid}
  91. The current process ID.
  92. Examples::
  93. borg create /path/to/repo::{hostname}-{user}-{utcnow} ...
  94. borg create /path/to/repo::{hostname}-{now:%Y-%m-%d_%H:%M:%S} ...
  95. borg prune --prefix '{hostname}-' ...