Linux Labs

Storage / Stage 10 of 11

Rsync — mirrors, comparison and deletion boundaries

Not running Starting usually ~20 s
Leave the lesson

Step 6 of 8 · theory · 4 min

Mirrors and backup history

An exact copy repeats the source's mistakes too. Getting yesterday's state back takes something else.

A mirror holds a single state: whatever the source had at the last run. Delete a file from the source by mistake, and the next rsync --delete deletes it from the mirror as well. Break the configuration, and the mirror gets the broken one.

A past state comes back from saved versions: a nightly archive with the date in its name, or a program like restic that keeps dated versions of the data. How many versions to keep and when to drop old ones is set by the retention rules.

A mirror is the tool for an exact copy as of now: moving data to another disk, or a standby server with the same files.

Check yourself 1 question

Yesterday afternoon someone deleted orders.csv from source by mistake, and overnight rsync -a --delete source/ mirror/ ran. Where do you get the file now?

  • mirror lacks the file too: a reverse run brings back to source exactly what it already has.

  • The overnight run with --delete has already removed orders.csv from mirror: ls mirror will not show it.

  • A plan compares the two current trees, and the file is in neither: the output will be empty.

The mirror repeated the deletion, so the file survives only in a copy saved before it. Those copies and how long they are kept are set up separately from the sync.

Key points

  • A mirror holds one, latest state of the source and repeats its mistakes, deletions included.
  • A past state comes back from saved versions: dated archives or versions kept by a backup program.
Ubuntu 24.04
Loading…