Linux Labs

Storage / Stage 10 of 11

Rsync — mirrors, comparison and deletion boundaries

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 8 · on a machine · 4 min

A sync without errors

What you will learn

  • Explain what rsync looks at to decide a file needs copying, and when the -c option is needed.
  • Read a dry-run plan and predict from the source's trailing slash where files will land.
  • Keep --delete within bounds and tell a mirror apart from a history of backups.

~/sync-lab/mirror holds a copy of the source directory that nobody has updated for a while. A colleague asks you to update the copy with a single rsync command and check its settings.conf setting.

Exercise · look

Update the copy with one command

In ~/sync-lab, update mirror from source with rsync, then look at the setting in the copy and compare the two settings.conf files in the ls -l output.

First, predict

What will cat mirror/settings.conf print after the sync?

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
Check yourself 1 question

Why did rsync leave the old settings.conf in mirror?

  • data/orders.csv was in mirror too, and rsync updated it: cat mirror/data/orders.csv prints 1,42, as in source.

  • The source comes first and the destination second: source/ → mirror/. cat source/settings.conf still prints mode=stable.

  • The files in mirror belong to student, as ls -l shows, and rsync overwrote orders.csv next to it without errors.

rsync compared the size and modification time of the two settings.conf files, found them equal and skipped the file.

Ubuntu 24.04
Loading…