borg-diff.1 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .
  4. .nr rst2man-indent-level 0
  5. .
  6. .de1 rstReportMargin
  7. \\$1 \\n[an-margin]
  8. level \\n[rst2man-indent-level]
  9. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  10. -
  11. \\n[rst2man-indent0]
  12. \\n[rst2man-indent1]
  13. \\n[rst2man-indent2]
  14. ..
  15. .de1 INDENT
  16. .\" .rstReportMargin pre:
  17. . RS \\$1
  18. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  19. . nr rst2man-indent-level +1
  20. .\" .rstReportMargin post:
  21. ..
  22. .de UNINDENT
  23. . RE
  24. .\" indent \\n[an-margin]
  25. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  26. .nr rst2man-indent-level -1
  27. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  28. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  29. ..
  30. .TH "BORG-DIFF" "1" "2025-10-31" "" "borg backup tool"
  31. .SH NAME
  32. borg-diff \- Diff contents of two archives
  33. .SH SYNOPSIS
  34. .sp
  35. borg [common options] diff [options] REPO::ARCHIVE1 ARCHIVE2 [PATH...]
  36. .SH DESCRIPTION
  37. .sp
  38. This command finds differences (file contents, user/group/mode) between archives.
  39. .sp
  40. A repository location and an archive name must be specified for REPO::ARCHIVE1.
  41. ARCHIVE2 is just another archive name in the same repository (no repository location
  42. allowed).
  43. .SS What is compared
  44. .sp
  45. For each matching item in both archives, Borg reports:
  46. .INDENT 0.0
  47. .IP \(bu 2
  48. Content changes: total added/removed bytes within files. If chunker parameters are comparable,
  49. Borg compares chunk IDs quickly; otherwise, it compares the content.
  50. .IP \(bu 2
  51. Metadata changes: user, group, mode, and other metadata shown inline like
  52. \(dq[old_mode \-> new_mode]\(dq for mode changes. Use \fB\-\-content\-only\fP to suppress metadata changes.
  53. .IP \(bu 2
  54. Added/removed items: printed as \(dqadded SIZE path\(dq or \(dqremoved SIZE path\(dq.
  55. .UNINDENT
  56. .SS Output formats
  57. .sp
  58. The default (text) output shows one line per changed path, e.g.:
  59. .INDENT 0.0
  60. .INDENT 3.5
  61. .sp
  62. .EX
  63. +135 B \-252 B [ \-rw\-r\-\-r\-\- \-> \-rwxr\-xr\-x ] path/to/file
  64. .EE
  65. .UNINDENT
  66. .UNINDENT
  67. .sp
  68. JSON Lines output (\fB\-\-json\-lines\fP) prints one JSON object per changed path, e.g.:
  69. .INDENT 0.0
  70. .INDENT 3.5
  71. .sp
  72. .EX
  73. {\(dqpath\(dq: \(dqPATH\(dq, \(dqchanges\(dq: [
  74. {\(dqtype\(dq: \(dqmodified\(dq, \(dqadded\(dq: BYTES, \(dqremoved\(dq: BYTES},
  75. {\(dqtype\(dq: \(dqmode\(dq, \(dqold_mode\(dq: \(dq\-rw\-r\-\-r\-\-\(dq, \(dqnew_mode\(dq: \(dq\-rwxr\-xr\-x\(dq},
  76. {\(dqtype\(dq: \(dqadded\(dq, \(dqsize\(dq: SIZE},
  77. {\(dqtype\(dq: \(dqremoved\(dq, \(dqsize\(dq: SIZE}
  78. ]}
  79. .EE
  80. .UNINDENT
  81. .UNINDENT
  82. .sp
  83. Only actual changes are included in the \(dqchanges\(dq list. For example, a modified entry with
  84. added=0 and removed=0 is omitted.
  85. .SS Sorting
  86. .sp
  87. Use \fB\-\-sort\-by FIELDS\fP where FIELDS is a comma\-separated list of fields.
  88. Sorts are applied stably from last to first in the given list. Prepend \(dq>\(dq for
  89. descending, \(dq<\(dq (or no prefix) for ascending, for example \fB\-\-sort\-by=\(dq>size_added,path\(dq\fP\&.
  90. Supported fields include:
  91. .INDENT 0.0
  92. .IP \(bu 2
  93. path: the item path
  94. .IP \(bu 2
  95. size_added: total bytes added for the item content
  96. .IP \(bu 2
  97. size_removed: total bytes removed for the item content
  98. .IP \(bu 2
  99. size_diff: size_added \- size_removed (net content change)
  100. .IP \(bu 2
  101. size: size of the item as stored in ARCHIVE2 (0 for removed items)
  102. .IP \(bu 2
  103. user, group, uid, gid, ctime, mtime: taken from the item state in ARCHIVE2 when present
  104. .IP \(bu 2
  105. ctime_diff, mtime_diff: timestamp difference (archive2 \- archive1)
  106. .UNINDENT
  107. .sp
  108. The \fB\-\-sort\fP option is deprecated and only sorts by path.
  109. .SS Performance considerations
  110. .sp
  111. For archives created with Borg 1.1 or newer, diff automatically detects whether
  112. the archives were created with the same chunker parameters. If so, only chunk IDs
  113. are compared, which is very fast.
  114. .sp
  115. For archives prior to Borg 1.1, chunk contents are compared by default.
  116. If you did not create the archives with different chunker parameters,
  117. pass \fB\-\-same\-chunker\-params\fP\&.
  118. Note that the chunker parameters changed from Borg 0.xx to 1.0.
  119. .sp
  120. For more help on include/exclude patterns, see the \fIborg_patterns\fP command output.
  121. .SH OPTIONS
  122. .sp
  123. See \fIborg\-common(1)\fP for common options of Borg commands.
  124. .SS arguments
  125. .INDENT 0.0
  126. .TP
  127. .B REPO::ARCHIVE1
  128. repository location and ARCHIVE1 name
  129. .TP
  130. .B ARCHIVE2
  131. ARCHIVE2 name (no repository location allowed)
  132. .TP
  133. .B PATH
  134. paths of items inside the archives to compare; patterns are supported
  135. .UNINDENT
  136. .SS options
  137. .INDENT 0.0
  138. .TP
  139. .B \-\-numeric\-owner
  140. deprecated, use \fB\-\-numeric\-ids\fP instead
  141. .TP
  142. .B \-\-numeric\-ids
  143. only consider numeric user and group identifiers
  144. .TP
  145. .B \-\-same\-chunker\-params
  146. Override check of chunker parameters.
  147. .TP
  148. .B \-\-sort
  149. Sort the output by path (deprecated, use \-\-sort\-by=path).
  150. .UNINDENT
  151. .IP "System Message: WARNING/2 (docs/borg-diff.rst:, line 119)"
  152. Option list ends without a blank line; unexpected unindent.
  153. .sp
  154. \-\-sort\-by FIELD[,FIELD...] Advanced sorting: specify field(s) to sort by. Accepts a comma\-separated list. Prefix with > for descending or < for ascending (default).
  155. \-\-content\-only Only compare differences in content (exclude metadata differences)
  156. \-\-json\-lines Format output as JSON Lines.
  157. .SS Include/Exclude options
  158. .INDENT 0.0
  159. .TP
  160. .BI \-e \ PATTERN\fR,\fB \ \-\-exclude \ PATTERN
  161. exclude paths matching PATTERN
  162. .TP
  163. .BI \-\-exclude\-from \ EXCLUDEFILE
  164. read exclude patterns from EXCLUDEFILE, one per line
  165. .TP
  166. .BI \-\-pattern \ PATTERN
  167. include/exclude paths matching PATTERN
  168. .TP
  169. .BI \-\-patterns\-from \ PATTERNFILE
  170. read include/exclude patterns from PATTERNFILE, one per line
  171. .UNINDENT
  172. .SH EXAMPLES
  173. .INDENT 0.0
  174. .INDENT 3.5
  175. .sp
  176. .EX
  177. $ borg init \-e=none testrepo
  178. $ mkdir testdir
  179. $ cd testdir
  180. $ echo asdf > file1
  181. $ dd if=/dev/urandom bs=1M count=4 > file2
  182. $ touch file3
  183. $ borg create ../testrepo::archive1 .
  184. $ chmod a+x file1
  185. $ echo \(dqsomething\(dq >> file2
  186. $ borg create ../testrepo::archive2 .
  187. $ echo \(dqtesting 123\(dq >> file1
  188. $ rm file3
  189. $ touch file4
  190. $ borg create ../testrepo::archive3 .
  191. $ cd ..
  192. $ borg diff testrepo::archive1 archive2
  193. [\-rw\-r\-\-r\-\- \-> \-rwxr\-xr\-x] file1
  194. +135 B \-252 B file2
  195. $ borg diff testrepo::archive2 archive3
  196. +17 B \-5 B file1
  197. added 0 B file4
  198. removed 0 B file3
  199. $ borg diff testrepo::archive1 archive3
  200. +17 B \-5 B [\-rw\-r\-\-r\-\- \-> \-rwxr\-xr\-x] file1
  201. +135 B \-252 B file2
  202. added 0 B file4
  203. removed 0 B file3
  204. $ borg diff \-\-json\-lines testrepo::archive1 archive3
  205. {\(dqpath\(dq: \(dqfile1\(dq, \(dqchanges\(dq: [{\(dqtype\(dq: \(dqmodified\(dq, \(dqadded\(dq: 17, \(dqremoved\(dq: 5}, {\(dqtype\(dq: \(dqmode\(dq, \(dqold_mode\(dq: \(dq\-rw\-r\-\-r\-\-\(dq, \(dqnew_mode\(dq: \(dq\-rwxr\-xr\-x\(dq}]}
  206. {\(dqpath\(dq: \(dqfile2\(dq, \(dqchanges\(dq: [{\(dqtype\(dq: \(dqmodified\(dq, \(dqadded\(dq: 135, \(dqremoved\(dq: 252}]}
  207. {\(dqpath\(dq: \(dqfile4\(dq, \(dqchanges\(dq: [{\(dqtype\(dq: \(dqadded\(dq, \(dqsize\(dq: 0}]}
  208. {\(dqpath\(dq: \(dqfile3\(dq, \(dqchanges\(dq: [{\(dqtype\(dq: \(dqremoved\(dq, \(dqsize\(dq: 0}]}
  209. # Use \-\-sort\-by with a comma\-separated list; sorts apply stably from last to first.
  210. # Here: primary by net size change descending, tie\-breaker by path ascending
  211. $ borg diff \-\-sort\-by=\(dq>size_diff,path\(dq testrepo::archive1 archive3
  212. +17 B \-5 B [\-rw\-r\-\-r\-\- \-> \-rwxr\-xr\-x] file1
  213. removed 0 B file3
  214. added 0 B file4
  215. +135 B \-252 B file2
  216. .EE
  217. .UNINDENT
  218. .UNINDENT
  219. .SH SEE ALSO
  220. .sp
  221. \fIborg\-common(1)\fP
  222. .SH AUTHOR
  223. The Borg Collective
  224. .\" Generated by docutils manpage writer.
  225. .