borg-diff.1 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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-12-23" "" "borg backup tool"
  31. .SH NAME
  32. borg-diff \- Finds differences between two archives.
  33. .SH SYNOPSIS
  34. .sp
  35. borg [common options] diff [options] ARCHIVE1 ARCHIVE2 [PATH...]
  36. .SH DESCRIPTION
  37. .sp
  38. This command finds differences (file contents, metadata) between ARCHIVE1 and ARCHIVE2.
  39. .sp
  40. For more help on include/exclude patterns, see the output of the \fIborg_patterns\fP command.
  41. .SH OPTIONS
  42. .sp
  43. See \fIborg\-common(1)\fP for common options of Borg commands.
  44. .SS arguments
  45. .INDENT 0.0
  46. .TP
  47. .B ARCHIVE1
  48. ARCHIVE1 name
  49. .TP
  50. .B ARCHIVE2
  51. ARCHIVE2 name
  52. .TP
  53. .B PATH
  54. paths of items inside the archives to compare; patterns are supported.
  55. .UNINDENT
  56. .SS options
  57. .INDENT 0.0
  58. .TP
  59. .B \-\-numeric\-ids
  60. only consider numeric user and group identifiers
  61. .TP
  62. .B \-\-same\-chunker\-params
  63. override the check of chunker parameters
  64. .TP
  65. .BI \-\-format \ FORMAT
  66. specify format for differences between archives (default: \(dq{change} {path}{NL}\(dq)
  67. .TP
  68. .B \-\-json\-lines
  69. Format output as JSON Lines.
  70. .TP
  71. .B \-\-sort\-by
  72. Sort output by comma\-separated fields (e.g., \(aq>size_added,path\(aq).
  73. .TP
  74. .B \-\-content\-only
  75. Only compare differences in content (exclude metadata differences)
  76. .UNINDENT
  77. .SS Include/Exclude options
  78. .INDENT 0.0
  79. .TP
  80. .BI \-e \ PATTERN\fR,\fB \ \-\-exclude \ PATTERN
  81. exclude paths matching PATTERN
  82. .TP
  83. .BI \-\-exclude\-from \ EXCLUDEFILE
  84. read exclude patterns from EXCLUDEFILE, one per line
  85. .TP
  86. .BI \-\-pattern \ PATTERN
  87. include/exclude paths matching PATTERN
  88. .TP
  89. .BI \-\-patterns\-from \ PATTERNFILE
  90. read include/exclude patterns from PATTERNFILE, one per line
  91. .UNINDENT
  92. .SH EXAMPLES
  93. .INDENT 0.0
  94. .INDENT 3.5
  95. .sp
  96. .EX
  97. $ borg diff archive1 archive2
  98. +17 B \-5 B [\-rw\-r\-\-r\-\- \-> \-rwxr\-xr\-x] file1
  99. +135 B \-252 B file2
  100. added 0 B file4
  101. removed 0 B file3
  102. $ borg diff archive1 archive2
  103. {\(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}]}
  104. {\(dqpath\(dq: \(dqfile2\(dq, \(dqchanges\(dq: [{\(dqtype\(dq: \(dqmodified\(dq, \(dqadded\(dq: 135, \(dqremoved\(dq: 252}]}
  105. {\(dqpath\(dq: \(dqfile4\(dq, \(dqchanges\(dq: [{\(dqtype\(dq: \(dqadded\(dq, \(dqsize\(dq: 0}]}
  106. {\(dqpath\(dq: \(dqfile3\(dq, \(dqchanges\(dq: [{\(dqtype\(dq: \(dqremoved\(dq, \(dqsize\(dq: 0}]}
  107. # Use \-\-sort\-by with a comma\-separated list; sorts apply stably from last to first.
  108. # Here: primary by net size change descending, tie\-breaker by path ascending
  109. $ borg diff \-\-sort\-by=\(dq>size_diff,path\(dq archive1 archive2
  110. +17 B \-5 B [\-rw\-r\-\-r\-\- \-> \-rwxr\-xr\-x] file1
  111. removed 0 B file3
  112. added 0 B file4
  113. +135 B \-252 B file2
  114. .EE
  115. .UNINDENT
  116. .UNINDENT
  117. .SH NOTES
  118. .SS The FORMAT specifier syntax
  119. .sp
  120. The \fB\-\-format\fP option uses Python\(aqs format string syntax <https://docs.python.org/3.10/library/string.html#formatstrings>
  121. \&.
  122. .sp
  123. Examples:
  124. .INDENT 0.0
  125. .INDENT 3.5
  126. .sp
  127. .EX
  128. $ borg diff \-\-format \(aq{content:30} {path}{NL}\(aq ArchiveFoo ArchiveBar
  129. modified: +4.1 kB \-1.0 kB file\-diff
  130. \&...
  131. # {VAR:<NUMBER} \- pad to NUMBER columns left\-aligned.
  132. # {VAR:>NUMBER} \- pad to NUMBER columns right\-aligned.
  133. $ borg diff \-\-format \(aq{content:>30} {path}{NL}\(aq ArchiveFoo ArchiveBar
  134. modified: +4.1 kB \-1.0 kB file\-diff
  135. \&...
  136. .EE
  137. .UNINDENT
  138. .UNINDENT
  139. .sp
  140. The following keys are always available:
  141. .INDENT 0.0
  142. .IP \(bu 2
  143. NEWLINE: OS dependent line separator
  144. .IP \(bu 2
  145. NL: alias of NEWLINE
  146. .IP \(bu 2
  147. NUL: NUL character for creating print0 / xargs \-0 like output
  148. .IP \(bu 2
  149. SPACE: space character
  150. .IP \(bu 2
  151. TAB: tab character
  152. .IP \(bu 2
  153. CR: carriage return character
  154. .IP \(bu 2
  155. LF: line feed character
  156. .UNINDENT
  157. .sp
  158. Keys available only when showing differences between archives:
  159. .INDENT 0.0
  160. .IP \(bu 2
  161. path: archived file path
  162. .IP \(bu 2
  163. change: all available changes
  164. .IP \(bu 2
  165. content: file content change
  166. .IP \(bu 2
  167. mode: file mode change
  168. .IP \(bu 2
  169. type: file type change
  170. .IP \(bu 2
  171. owner: file owner (user/group) change
  172. .IP \(bu 2
  173. group: file group change
  174. .IP \(bu 2
  175. user: file user change
  176. .IP \(bu 2
  177. link: file link change
  178. .IP \(bu 2
  179. directory: file directory change
  180. .IP \(bu 2
  181. blkdev: file block device change
  182. .IP \(bu 2
  183. chrdev: file character device change
  184. .IP \(bu 2
  185. fifo: file fifo change
  186. .IP \(bu 2
  187. mtime: file modification time change
  188. .IP \(bu 2
  189. ctime: file change time change
  190. .IP \(bu 2
  191. isomtime: file modification time change (ISO 8601)
  192. .IP \(bu 2
  193. isoctime: file creation time change (ISO 8601)
  194. .UNINDENT
  195. .SS What is compared
  196. .sp
  197. For each matching item in both archives, Borg reports:
  198. .INDENT 0.0
  199. .IP \(bu 2
  200. Content changes: total added/removed bytes within files. If chunker parameters are comparable,
  201. Borg compares chunk IDs quickly; otherwise, it compares the content.
  202. .IP \(bu 2
  203. Metadata changes: user, group, mode, and other metadata shown inline, like
  204. \(dq[old_mode \-> new_mode]\(dq for mode changes. Use \fB\-\-content\-only\fP to suppress metadata changes.
  205. .IP \(bu 2
  206. Added/removed items: printed as \(dqadded SIZE path\(dq or \(dqremoved SIZE path\(dq.
  207. .UNINDENT
  208. .SS Output formats
  209. .sp
  210. The default (text) output shows one line per changed path, e.g.:
  211. .INDENT 0.0
  212. .INDENT 3.5
  213. .sp
  214. .EX
  215. +135 B \-252 B [ \-rw\-r\-\-r\-\- \-> \-rwxr\-xr\-x ] path/to/file
  216. .EE
  217. .UNINDENT
  218. .UNINDENT
  219. .sp
  220. JSON Lines output (\fB\-\-json\-lines\fP) prints one JSON object per changed path, e.g.:
  221. .INDENT 0.0
  222. .INDENT 3.5
  223. .sp
  224. .EX
  225. {\(dqpath\(dq: \(dqPATH\(dq, \(dqchanges\(dq: [
  226. {\(dqtype\(dq: \(dqmodified\(dq, \(dqadded\(dq: BYTES, \(dqremoved\(dq: BYTES},
  227. {\(dqtype\(dq: \(dqmode\(dq, \(dqold_mode\(dq: \(dq\-rw\-r\-\-r\-\-\(dq, \(dqnew_mode\(dq: \(dq\-rwxr\-xr\-x\(dq},
  228. {\(dqtype\(dq: \(dqadded\(dq, \(dqsize\(dq: SIZE},
  229. {\(dqtype\(dq: \(dqremoved\(dq, \(dqsize\(dq: SIZE}
  230. ]}
  231. .EE
  232. .UNINDENT
  233. .UNINDENT
  234. .SS Sorting
  235. .sp
  236. Use \fB\-\-sort\-by FIELDS\fP where FIELDS is a comma\-separated list of fields.
  237. Sorts are applied stably from last to first in the given list. Prepend \(dq>\(dq for
  238. descending, \(dq<\(dq (or no prefix) for ascending, for example \fB\-\-sort\-by=\(dq>size_added,path\(dq\fP\&.
  239. Supported fields include:
  240. .INDENT 0.0
  241. .IP \(bu 2
  242. path: the item path
  243. .IP \(bu 2
  244. size_added: total bytes added for the item content
  245. .IP \(bu 2
  246. size_removed: total bytes removed for the item content
  247. .IP \(bu 2
  248. size_diff: size_added \- size_removed (net content change)
  249. .IP \(bu 2
  250. size: size of the item as stored in ARCHIVE2 (0 for removed items)
  251. .IP \(bu 2
  252. user, group, uid, gid, ctime, mtime: taken from the item state in ARCHIVE2 when present
  253. .IP \(bu 2
  254. ctime_diff, mtime_diff: timestamp difference (ARCHIVE2 \- ARCHIVE1)
  255. .UNINDENT
  256. .SS Performance considerations
  257. .sp
  258. diff automatically detects whether the archives were created with the same chunker
  259. parameters. If so, only chunk IDs are compared, which is very fast.
  260. .SH SEE ALSO
  261. .sp
  262. \fIborg\-common(1)\fP
  263. .SH AUTHOR
  264. The Borg Collective
  265. .\" Generated by docutils manpage writer.
  266. .