A mistake in an rsync command is best seen before rsync changes anything. That is what a dry run is for.
A dry run is the -n option: rsync compares the trees and prints what it would do, but changes nothing. The -i option prints one line per change, and the path at the end of the line is relative to the destination directory:
| Line starts with | What rsync will do |
|---|---|
>f+++++++++ |
send a new file |
>f..t...... |
update a file with a different time; s in place of a dot means size, c means contents |
cd+++++++++ |
create a directory |
Compare two plans for the same pair of directories: the commands differ by one character.
Compare two plans
In ~/sync-lab, run two dry runs: one with source as the source and one with source/. Copy nothing.
First, predict
Where will the first plan put settings.conf?
Now start the exercise, run the command and compare your prediction with the output.
The trailing slash on the source decides what gets copied. source/ means the directory's contents: source/new.txt becomes mirror/new.txt. source without the slash means the directory itself: mirror/source/ appears inside the destination with every file.