Linux Labs

Storage / Stage 10 of 11

Rsync — mirrors, comparison and deletion boundaries

Not running Starting usually ~20 s
Leave the lesson

Step 3 of 8 · on a machine · 6 min

The plan before the run

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.

Exercise · look

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.

Sign in and start The machine is available after signing in

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.

Ubuntu 24.04
Loading…