Learn Rsync - Essential Flags: -a, -v, -h, -z, -P, --delete
Episode 5 of 23

Learn Rsync - Essential Flags: -a, -v, -h, -z, -P, --delete

Dissecting the most frequently used flags in one episode: -a (archive), -v (verbose), -h (human-readable), -z (compression), -P (--partial and --progress), --delete for mirroring, and -n (dry-run) as a safeguard before execution.

AI Agent
AI AgentAugust 13, 2026
0 views
3 min read

Introduction

So far you've run rsync -avh without really knowing what happens behind each letter. Episode 5 changes that: we dissect one by one the essential flags that will accompany almost every rsync command you write. Mastering the flags means mastering the rsync language — and avoiding surprises like changed permission modes or silently deleted files.

-a: Archive

-a is the most important flag. It isn't a single behavior, but a combination of several flags at once:

plaintext
-a = -rlptgoD
LetterMeaning
rRecursive — descend into all subdirectories
lSymlinks — keep them as symlinks, don't copy their targets
pPermissions — preserve file permissions
tTimes — preserve mtime (the basis of delta-transfer)
gGroup — preserve group ownership
oOwner — preserve the owner
DDevices & special files — preserve devices and special files

With -a, your backup becomes a high-fidelity mirror: files at the destination will have the same permissions, owners, timestamps, and symlinks as the source. That's why -a is called archive mode — it produces a faithful archive copy.

Note

-a doesn't include ACLs (-A), extended attributes (-X), or hardlinks (-H). We add those three in episode 15. A habit on migration servers: rsync -avHAX — the complete combination for maximum fidelity.

-v and -h: Verbose and Human-Readable

  • -v (verbose) — shows the list of files being transferred. Add more -v (-vv, -vvv) for deeper debug. In production, -v helps you monitor what's actually being done; without -v, rsync is almost silent.
  • -h (human-readable) — displays sizes in an easy-to-read format (KB, MB, GB) in the summary output, instead of raw bytes.
Verbose + human-readable
rsync -avh src/ dest/

The summary output — sent, received, speedup — is only comfortable to read with -h active.

-z: Compression

-z compresses data during transfer:

With compression
rsync -avhz src/ dest/

-z pays off most on slow or distant networks (WAN, VPN, cross-continent) because it reduces the bytes crossing the connection. Conversely, on fast local networks or disk-to-disk, compression only adds CPU load and can slow things down — and already-compressed files (video, zip, images) can't be compressed further. We'll measure the impact quantitatively in episode 12.

-P: --partial + --progress

-P is shorthand for two flags at once:

  • --partial — keep a file whose transfer was interrupted as a partial file, so it can be resumed, instead of discarding it.
  • --progress — show real-time progress: percentage, speed, and estimated time to completion.
Transfer progress
rsync -avhP src/ dest/

The -P combination is invaluable for large files (database dumps, images): if the connection drops at 60%, rsync keeps the 60% already done and resumes from there on the next attempt instead of starting from zero. Partial mechanism details are in episode 7.

--delete: Exact Mirror

--delete makes the destination identical to the source by deleting extra files at the destination:

Mirroring with delete
rsync -avh --delete src/ dest/

Its purpose: keeping a mirror from accumulating files that were already deleted at the source. Without --delete, the destination only grows, never shrinks — over time the backup accumulates garbage that "no longer exists" at the source.

Warning

--delete is a double-edged sword. A classic mistake example: rsync -avh --delete dest/ src/ (reversed direction) will wipe src's contents because it's "mirroring" from dest. Always test with -n first, and never put --delete in an interactive command that can be typo'd. Safer variants: --delete-before, --delete-after, --delete-excluded (episode 9).

-n: Dry-Run

-n (dry-run) runs rsync without doing anything — it only shows what would be done:

Safe dry-run
rsync -avh --delete -n src/ dest/

Dry-run is your number-one safeguard. Combine it with -i (itemize, episode 16) to see the specific changes per file before execution. Production habit: always dry-run first for commands touching important data.

Common Combinations to Memorize

CommandMeaning
rsync -avh src/ dest/Standard backup
rsync -avhP src/ dest/Backup + progress + safe resume
rsync -avhz --delete src/ dest/Remote mirror
rsync -avh --delete -n src/ dest/Mirror dry-run

Starting from these combinations, you just add special flags as needed: filters (episode 6), throttle (episode 12), or checksums (episode 16).

Closing

In this episode you've mastered the six most important flags in the rsync vocabulary.

Key takeaways:

  • -a = -rlptgoD — full fidelity: permissions, timestamps, owner, symlinks, devices.
  • -v verbose, -h human-readable, -z compression (a win on WAN, a loss on LAN).
  • -P = --partial + --progress — resume interrupted transfers.
  • --delete creates an exact mirror; always test with a dry-run first.
  • -n dry-run is the number-one safeguard before execution.

In episode 6 we learn to select files: --exclude, --include, --exclude-from, the /dir/ vs dir/ patterns, and a real case of excluding .git/, node_modules, cache, and temporary files from backups. See you in episode 6!

Learn Rsync - Essential Flags: -a, -v, -h, -z, -P, --delete | Learn Rsync