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 backup --dry-run -vv lists what a backup would add before it writes

Backup
~/tips/tip-backup-restic-backup-dry-run

restic -r /srv/restic-repo backup /mnt/user/appdata --dry-run -vv

Shows which files a restic backup would process, so you can test your excludes without making a snapshot.

Every time I change an exclude pattern, I wonder what it really caught. Restic can answer that without touching the repository: --dry-run (or -n) reports what would be done without writing anything.

restic -r /srv/restic-repo backup /mnt/user/appdata --dry-run -vv

With -vv restic prints the files it would process, with a status for each one. The docs use the same combination and filter it with grep to see only the files that would be added:

restic -r /srv/restic-repo backup /mnt/user/appdata --dry-run -vv | grep "added"

I find this most useful while building the list of exclusions. Add one --exclude pattern, run the dry run again, and see whether the noisy folder disappeared from the output. Doing that for real would create a snapshot for every experiment.

A caveat from the docs is worth remembering when you test excludes: excludes do not apply to backup sources that you pass explicitly on the command line. If you name /mnt/user/appdata/cache as a source and also exclude it, restic still backs it up. Patterns only filter what is found below the sources. Case matters as well. --exclude is case-sensitive, and --iexclude is the variant that ignores case.

A dry run also still has to walk the folders, so on a big tree it takes a while to finish, though it writes nothing. That is still faster than finding out next week that a cache folder of several gigabytes ended up in every snapshot.

Further reading: restic docs: Backing up (dry run and excludes)

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