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: restic diff shows what changed between two backup snapshots

Backup
~/tips/tip-backup-restic-diff

restic -r sftp:[email protected]:/restic-repo snapshots

Lists the files that were added, removed or changed between two restic snapshots.

When a nightly backup suddenly takes much longer, or the repository grows a lot more than usual, I want to know one thing: what changed? restic can tell you without restoring anything.

List the snapshots to get their IDs, then compare two of them:

restic -r sftp:[email protected]:/restic-repo snapshots
restic -r sftp:[email protected]:/restic-repo diff 5845b002 2ab627a6

The output lists every path that differs, with a character in front: + added, - removed, M file content changed, T entry type changed. A ? means restic detected bitrot. Underneath you get a short statistic with new, removed and changed files and directories, and how much data was added to and removed from the repository.

For appdata I’d narrow it down to one folder with the snapshot:subfolder syntax, where the subfolder is a path inside the snapshot as restic ls shows it:

restic -r sftp:[email protected]:/restic-repo diff 5845b002:/mnt/user/appdata 2ab627a6:/mnt/user/appdata

If one container’s folder fills the list with thousands of changed cache files or thumbnails, that folder is a good candidate for an exclude. You can also write latest instead of an ID.

One caveat: by default diff only reports changes in file contents. Files whose permissions or owner changed don’t show up unless you add --metadata, and then they get a U. Keep that in mind after a big chown or chmod on a share, which changes a lot of metadata and no content at all.

Further reading: restic docs: comparing snapshots

More Backup tips restic snapshots --group-by host,paths mysqldump --routines --events mydb > mydb.sql rsync -a --files-from=list.txt /home/me/ backup:/backup/ restic find "*.txt" restic stats All Backup tips (45) All topics

Link