brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: borg diff shows what changed between two Borg archives

Linux
~/tips/tip-backup-borg-diff-archives

borg diff /path/to/repo::archive1 archive2

Lists files added, removed and changed between two archives in a Borg repository.

Before I delete old backups, I like to know what is actually different between two of them. Borg can answer that without extracting anything: borg diff compares two archives in a repository.

borg diff /path/to/repo::archive1 archive2

The first archive needs the repository location. The second is just a name in the same repository. For each changed path you get one line, for example:

+135 B    -252 B [ -rw-r--r-- -> -rwxr-xr-x ] path/to/file
added           0 B file4
removed         0 B file3

That means: 135 bytes added and 252 removed in a file whose mode changed, one new file and one removed file. The docs say it compares content, user and group, and mode.

A few options make it more useful. --content-only hides the metadata changes, which is handy when only a permission change would otherwise drown the real edits. --sort-by accepts fields such as path, size_added or size_diff, and a leading > sorts descending, so this puts the biggest additions on top:

borg diff --sort-by='>size_added,path' /path/to/repo::archive1 archive2

For scripts there is --json-lines, and you can pass paths at the end to compare only one folder.

The caveat is speed and version. The docs say that for archives made with Borg 1.1 or newer, diff detects whether both archives used the same chunker parameters and, if so, compares only chunk IDs, which is very fast. Older archives are compared by content, and the docs mention --same-chunker-params for that case. These details come from the Borg 1.4.5 documentation, so check your own version.

Further reading: Borg documentation: borg diff

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link