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: rsync -ani shows exactly what would change before it changes anything

Backup
~/tips/tip-shell-rsync-dry-run-itemize

rsync -ani --delete ~/Documents/ /mnt/backup/Documents/

Prints what rsync would copy or delete, without touching any file.

Running rsync with --delete and hoping is a bad plan. The dry run costs a few seconds and shows you what would happen.

-n (--dry-run) does a trial run with no changes made. -i (--itemize-changes) prints a change summary for every file, one line each, with a short code in front that says what would happen: new file, changed size, changed time, and for deletions the word *deleting.

rsync -ani --delete ~/Documents/ /mnt/backup/Documents/
# looks right? run it again without -n

I like to keep the same line and just remove the n. Arrow up, delete one letter, Enter. That way the command you ran for real is the one you checked.

Caveats. A dry run does not catch every problem: it will not tell you that the disk is going to fill up halfway, or that a permission will fail. Newer rsync versions (3.x) are needed for the full itemize output, and macOS ships an old one, so install a current one with Homebrew if the output looks sparse. The long list of codes is explained in the man page under --itemize-changes.

Further reading: rsync man page, On this site: the trailing slash in rsync decides where your files land, On this site: rsync –info=progress2 shows one progress line for the whole transfer

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