borg/docs/usage/diff.rst
Thomas Waldmann df6f4201f8
docs: fix broken examples and stale output samples in the usage docs
All command lines were executed against scratch repositories and all
output samples regenerated from real runs (prettified, not invented):

- recreate: the example used the removed --recompress; show
  borg repo-compress instead; refresh the borg info samples.
- diff: default/text output has modified:/added:/removed: labels and
  mtime/ctime brackets now; the JSON-lines example used borg1 keys
  and lacked --json-lines on the command; add --content-only.
- mount: example passed the repository as a positional (it would have
  been taken as the mountpoint); use -r.
- tar: the archive-copy loop was a bash syntax error and used
  borg list with repo-list-only format keys; replaced with a working
  while-read loop over borg repo-list (verified end-to-end, identical
  archive contents in the destination repo).
- key: regenerate repo-create/change-passphrase samples (hex-id named
  keyfiles, Key location line, no "Synchronizing index"); the import
  example silently did nothing without --key-location=keyfile; fix
  the Windows keys path (AppData\Local, not Roaming); explain why the
  keyfile name changes on passphrase change.
- transfer: the borg1->borg2 upgrade steps were missing --from-borg1
  and used a ssh:// destination URL (rejected for current repos);
  fix the Windows keys path.
- notes: --noatime and --nobsdflags no longer exist (atime is opt-in
  via --atime); stray "|" removed.
- compact: segments wording removed.
- info/repo-info/repo-delete/list/find: output samples regenerated
  (new labels/order, UTC offsets, repo version line, prompt text;
  isomtime format and symlink size corrected in list).
- general: fix broken inline markup (stray backtick).
- serve: the authorized_keys forced command needs --rest (it is
  deliberately not client-suppliable); document the actual client
  argument allowlist including --backend.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-28 12:48:17 +02:00

36 lines
2.1 KiB
ReStructuredText

.. include:: diff.rst.inc
Examples
~~~~~~~~
::
# By default, borg diff reports metadata changes (mode, mtime, ctime, ...) besides
# the content changes, so the lines can get quite long:
$ borg diff archive1 archive2
[mtime: Fri, 2026-08-28 12:26:23.433047048 +0200 -> Fri, 2026-08-28 12:26:24.204040020 +0200] [ctime: Fri, 2026-08-28 12:26:23.433047048 +0200 -> Fri, 2026-08-28 12:26:24.204040020 +0200] .
modified: +17 B -5 B [-rw-r--r-- -> -rwxr-xr-x] [mtime: Fri, 2026-08-28 12:26:23.431245244 +0200 -> Fri, 2026-08-28 12:26:24.199251801 +0200] [ctime: Fri, 2026-08-28 12:26:23.431245244 +0200 -> Fri, 2026-08-28 12:26:24.200688313 +0200] file1
modified: +135 B -252 B [mtime: Fri, 2026-08-28 12:26:23.432895166 +0200 -> Fri, 2026-08-28 12:26:24.202236091 +0200] [ctime: Fri, 2026-08-28 12:26:23.432895166 +0200 -> Fri, 2026-08-28 12:26:24.202236091 +0200] file2
added: 0 B file4
removed: 0 B file3
# --content-only hides the metadata changes and only reports content differences:
$ borg diff --content-only archive1 archive2
modified: +17 B -5 B file1
modified: +135 B -252 B file2
added: 0 B file4
removed: 0 B file3
# Use --json-lines to get one JSON object per changed path:
$ borg diff --json-lines --content-only archive1 archive2
{"changes": [{"added": 17, "removed": 5, "type": "modified"}], "path": "file1"}
{"changes": [{"added": 135, "removed": 252, "type": "modified"}], "path": "file2"}
{"changes": [{"added": 0, "removed": 0, "type": "added"}], "path": "file4"}
{"changes": [{"added": 0, "removed": 0, "type": "removed"}], "path": "file3"}
# Use --sort-by with a comma-separated list; sorts apply stably from last to first.
# Here: primary by net size change descending, tie-breaker by path ascending
$ borg diff --content-only --sort-by=">size_diff,path" archive1 archive2
modified: +17 B -5 B file1
removed: 0 B file3
added: 0 B file4
modified: +135 B -252 B file2