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