diff.rst.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. .. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!
  2. .. _borg_diff:
  3. borg diff
  4. ---------
  5. .. code-block:: none
  6. borg [common options] diff [options] ARCHIVE1 ARCHIVE2 [PATH...]
  7. .. only:: html
  8. .. class:: borg-options-table
  9. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  10. | **positional arguments** |
  11. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  12. | | ``ARCHIVE1`` | ARCHIVE1 name |
  13. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  14. | | ``ARCHIVE2`` | ARCHIVE2 name |
  15. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  16. | | ``PATH`` | paths of items inside the archives to compare; patterns are supported. |
  17. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  18. | **options** |
  19. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  20. | | ``--numeric-ids`` | only consider numeric user and group identifiers |
  21. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  22. | | ``--same-chunker-params`` | override the check of chunker parameters |
  23. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  24. | | ``--format FORMAT`` | specify format for differences between archives (default: "{change} {path}{NL}") |
  25. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  26. | | ``--json-lines`` | Format output as JSON Lines. |
  27. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  28. | | ``--sort-by`` | Sort output by comma-separated fields (e.g., '>size_added,path'). |
  29. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  30. | | ``--content-only`` | Only compare differences in content (exclude metadata differences) |
  31. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  32. | .. class:: borg-common-opt-ref |
  33. | |
  34. | :ref:`common_options` |
  35. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  36. | **Include/Exclude options** |
  37. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  38. | | ``-e PATTERN``, ``--exclude PATTERN`` | exclude paths matching PATTERN |
  39. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  40. | | ``--exclude-from EXCLUDEFILE`` | read exclude patterns from EXCLUDEFILE, one per line |
  41. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  42. | | ``--pattern PATTERN`` | include/exclude paths matching PATTERN |
  43. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  44. | | ``--patterns-from PATTERNFILE`` | read include/exclude patterns from PATTERNFILE, one per line |
  45. +-------------------------------------------------------+---------------------------------------+----------------------------------------------------------------------------------+
  46. .. raw:: html
  47. <script type='text/javascript'>
  48. $(document).ready(function () {
  49. $('.borg-options-table colgroup').remove();
  50. })
  51. </script>
  52. .. only:: latex
  53. ARCHIVE1
  54. ARCHIVE1 name
  55. ARCHIVE2
  56. ARCHIVE2 name
  57. PATH
  58. paths of items inside the archives to compare; patterns are supported.
  59. options
  60. --numeric-ids only consider numeric user and group identifiers
  61. --same-chunker-params override the check of chunker parameters
  62. --format FORMAT specify format for differences between archives (default: "{change} {path}{NL}")
  63. --json-lines Format output as JSON Lines.
  64. --sort-by Sort output by comma-separated fields (e.g., '>size_added,path').
  65. --content-only Only compare differences in content (exclude metadata differences)
  66. :ref:`common_options`
  67. |
  68. Include/Exclude options
  69. -e PATTERN, --exclude PATTERN exclude paths matching PATTERN
  70. --exclude-from EXCLUDEFILE read exclude patterns from EXCLUDEFILE, one per line
  71. --pattern PATTERN include/exclude paths matching PATTERN
  72. --patterns-from PATTERNFILE read include/exclude patterns from PATTERNFILE, one per line
  73. Description
  74. ~~~~~~~~~~~
  75. This command finds differences (file contents, metadata) between ARCHIVE1 and ARCHIVE2.
  76. For more help on include/exclude patterns, see the output of the :ref:`borg_patterns` command.
  77. .. man NOTES
  78. The FORMAT specifier syntax
  79. +++++++++++++++++++++++++++
  80. The ``--format`` option uses Python's `format string syntax
  81. <https://docs.python.org/3.10/library/string.html#formatstrings>`_.
  82. Examples:
  83. ::
  84. $ borg diff --format '{content:30} {path}{NL}' ArchiveFoo ArchiveBar
  85. modified: +4.1 kB -1.0 kB file-diff
  86. ...
  87. # {VAR:<NUMBER} - pad to NUMBER columns left-aligned.
  88. # {VAR:>NUMBER} - pad to NUMBER columns right-aligned.
  89. $ borg diff --format '{content:>30} {path}{NL}' ArchiveFoo ArchiveBar
  90. modified: +4.1 kB -1.0 kB file-diff
  91. ...
  92. The following keys are always available:
  93. - NEWLINE: OS dependent line separator
  94. - NL: alias of NEWLINE
  95. - NUL: NUL character for creating print0 / xargs -0 like output
  96. - SPACE: space character
  97. - TAB: tab character
  98. - CR: carriage return character
  99. - LF: line feed character
  100. Keys available only when showing differences between archives:
  101. - path: archived file path
  102. - change: all available changes
  103. - content: file content change
  104. - mode: file mode change
  105. - type: file type change
  106. - owner: file owner (user/group) change
  107. - group: file group change
  108. - user: file user change
  109. - link: file link change
  110. - directory: file directory change
  111. - blkdev: file block device change
  112. - chrdev: file character device change
  113. - fifo: file fifo change
  114. - mtime: file modification time change
  115. - ctime: file change time change
  116. - isomtime: file modification time change (ISO 8601)
  117. - isoctime: file creation time change (ISO 8601)
  118. What is compared
  119. +++++++++++++++++
  120. For each matching item in both archives, Borg reports:
  121. - Content changes: total added/removed bytes within files. If chunker parameters are comparable,
  122. Borg compares chunk IDs quickly; otherwise, it compares the content.
  123. - Metadata changes: user, group, mode, and other metadata shown inline, like
  124. "[old_mode -> new_mode]" for mode changes. Use ``--content-only`` to suppress metadata changes.
  125. - Added/removed items: printed as "added SIZE path" or "removed SIZE path".
  126. Output formats
  127. ++++++++++++++
  128. The default (text) output shows one line per changed path, e.g.::
  129. +135 B -252 B [ -rw-r--r-- -> -rwxr-xr-x ] path/to/file
  130. JSON Lines output (``--json-lines``) prints one JSON object per changed path, e.g.::
  131. {"path": "PATH", "changes": [
  132. {"type": "modified", "added": BYTES, "removed": BYTES},
  133. {"type": "mode", "old_mode": "-rw-r--r--", "new_mode": "-rwxr-xr-x"},
  134. {"type": "added", "size": SIZE},
  135. {"type": "removed", "size": SIZE}
  136. ]}
  137. Sorting
  138. ++++++++
  139. Use ``--sort-by FIELDS`` where FIELDS is a comma-separated list of fields.
  140. Sorts are applied stably from last to first in the given list. Prepend ">" for
  141. descending, "<" (or no prefix) for ascending, for example ``--sort-by=">size_added,path"``.
  142. Supported fields include:
  143. - path: the item path
  144. - size_added: total bytes added for the item content
  145. - size_removed: total bytes removed for the item content
  146. - size_diff: size_added - size_removed (net content change)
  147. - size: size of the item as stored in ARCHIVE2 (0 for removed items)
  148. - user, group, uid, gid, ctime, mtime: taken from the item state in ARCHIVE2 when present
  149. - ctime_diff, mtime_diff: timestamp difference (ARCHIVE2 - ARCHIVE1)
  150. Performance considerations
  151. ++++++++++++++++++++++++++
  152. diff automatically detects whether the archives were created with the same chunker
  153. parameters. If so, only chunk IDs are compared, which is very fast.