File backup tools
Copy a tree with rsync
Create an incremental file copy, preview changes, preserve metadata, and avoid accidental deletion.
rsync updates a destination tree efficiently. On the first run it copies everything. On every run after that, it transfers only what changed. This makes it ideal for pushing a working directory to an external disk or a remote server.
Let’s be clear about one thing up front. One synchronized destination is not version history. rsync gives you the current state, mirrored. Yesterday’s version of a file disappears from the mirror the moment you sync today’s.
Preview, then copy
Always preview before copying. The first command shows what would happen, the second does it:
rsync --archive --dry-run --itemize-changes notes/ /Volumes/Backup/notes/
rsync --archive --itemize-changes notes/ /Volumes/Backup/notes/
--archive (or -a) preserves permissions, timestamps, symlinks, and ownership where possible. You almost always want it. --dry-run shows what would happen without touching anything. --itemize-changes prints one line per affected file:
>f+++++++++ report.txt
>f.st...... budget.md
>f+++++++++ means a new file is being created. >f.st...... means an existing file is being updated because its size and modification time differ.
Now modify, add, and remove a file in the source. Run the dry run again and explain every proposed line to yourself before running the real command. When a second dry run prints nothing, source and destination are in sync. That silence is your verification.
Trailing slashes and —delete
Be very careful with two things: the trailing slash on the source, and --delete.
The trailing slash changes the meaning. notes/ means “the contents of notes”. notes means “the directory itself”. Get it wrong and you end up with /Volumes/Backup/notes/notes/. Your next sync then compares the wrong trees.
--delete removes destination files that no longer exist in the source. It’s what keeps a mirror honest. It also turns rsync into a tool that destroys data. Swap source and destination by mistake, and you sync an empty new laptop to your backup disk. With --delete, the backup is now empty too.
My rule: dry-run any command that includes --delete, every single time. Even the one I ran yesterday.
Lesson completed