Linux

rsync Command Builder

Build an rsync command with the trailing-slash rule and the cost of --delete made explicit.

Transfer

rsync decides this from the trailing slash alone, which is why the same command run twice with a one-character difference produces two different layouts.

source: /var/www/site/

result: /var/www/site/…

Options

Shorthand for -rlptgoD: recursive, symlinks, permissions, times, group, owner, devices. Without it, timestamps are not preserved and every run re-sends everything.

Worth it over a slow link, a loss on a LAN or for data that is already compressed.

Makes the destination match the source exactly, including removing files. Rehearse it with a dry run.

Reports what would change and transfers nothing.

Per-file progress. Combined with --partial it becomes -P.

An interrupted transfer resumes instead of starting the file again.

Reads every byte on both sides. Correct when mtimes are unreliable, wasteful otherwise.

Keeps the raw uid/gid instead of mapping them through user names. Wanted for backups.

Prints a per-file code saying why it was transferred.

Lists the files as they transfer.

Prints sizes as K, M and G rather than raw bytes.

Excludes

One pattern per line. A leading slash anchors the pattern to the transfer root rather than the filesystem root; a trailing slash matches directories only.

SSH

These become a single -e 'ssh …' argument, because -e replaces the remote shell command entirely rather than adding to it.

Command
dry run
rsync -avzhP --dry-run --exclude=.git/ --exclude=node_modules/ --exclude='*.log' /var/www/site/ [email protected]:/var/www/site/
  • InfoThe trailing slash on the source means the contents of /var/www/site are copied into the destination.
  • Info-a is shorthand for -rlptgoD. Preserving owner (-o), group (-g) and devices (-D) needs root at the receiving end; as an ordinary user those parts fail while the rest succeeds.
  • Low-z costs CPU on both ends. It pays for itself over a slow link and loses on a LAN or when the files are already compressed (images, video, archives).
  • LowWithout --numeric-ids, uid/gid are mapped through user names on the far side. For a backup you want the raw numbers preserved.

Presets

Built in your browser — nothing is transferred from here