rsync Command Builder

Generate rsync commands visually. Toggle flags, add excludes, set the SSH port, then copy the result.

Client-side only. Nothing leaves your browser

Trailing slash copies contents. No slash copies the directory itself.

Remote format: user@host:/absolute/path

One pattern per line. Each becomes a separate --exclude flag. Glob syntax: *, **, ?.

rsync -avzPh --exclude=node_modules --exclude=.git --exclude='*.log' /home/me/projects/ [email protected]:/srv/backups/projects/
commandflagpathvalue
Built a command? Paste it into the rsync Flag Explainer to verify what each flag does before you run it on a real server.

What does the rsync command do?

rsync (short for "remote sync") is the standard Unix utility for copying and synchronizing files between two local paths, between a local machine and a remote server over SSH, or between two remote servers. Its defining feature is the delta-transfer algorithm: rsync only sends the bytes that have changed since the last run, so re-syncing a large tree is dramatically faster than scp, cp, or a fresh copy. The trade-off is that rsync's behavior is governed almost entirely by flags, and getting one wrong (a missing trailing slash, an unguarded --delete) can wipe data on the destination. This builder generates correct commands for the common cases (push, pull, mirror, and incremental snapshot) so you don't have to memorize the syntax.

Anatomy of an rsync Command

Every rsync command has the same four-part structure. Source and destination are always the last two arguments. Everything before them is options:

rsync -avzP --exclude=node_modules /src/ user@host:/dst/
PartPurpose
rsyncThe binary. Must be installed on both sides for SSH transfers.
-avzPShort flags. Stack them in any order; -a is archive mode, -v verbose, -z compress, -P progress+partial.
--exclude=...Long flags with values. Skip files matching the pattern. Can be repeated.
/src/Source path. Local path or user@host:/path.
user@host:/dst/Destination. Same syntax as source. One of the two can be remote, but not both unless you use --rsh chaining.

Common rsync Command Patterns

These are the rsync commands that show up most often in scripts, Stack Overflow answers, and backup playbooks:

Push a local folder to a remote server

rsync -avzP /home/me/projects/ user@host:/backups/projects/

Pull a remote folder down to your laptop

rsync -avzP user@host:/var/www/ ./site-backup/

Sync between two servers over SSH on a custom port

rsync -avzP -e 'ssh -p 2222' /src/ user@host:/dst/

Mirror with --delete (preview first with -n)

rsync -avn --delete /src/ /backup/

Snapshot-style backup hardlinked against yesterday

rsync -av --link-dest=/mnt/backup/yesterday/ /home/me/ /mnt/backup/today/

Bandwidth-capped transfer (10 MB/s)

rsync -avz --bwlimit=10M /src/ user@host:/dst/

Exclude multiple patterns

rsync -av --exclude=node_modules --exclude='*.log' /src/ /dst/

rsync Flags Cheat Sheet

FlagLong formWhat it does
-a--archiveRecursive copy that preserves permissions, times, owner, group, symlinks, and devices. The base flag for almost every rsync command.
-v--verbosePrint each filename as it transfers. Use -vv or -vvv for more detail.
-z--compressCompress data in transit. Useful over SSH on slower networks; skip on a fast LAN or for already-compressed files.
-P--partial --progressShow a per-file progress bar and keep partial files on interrupt so transfers can resume.
-h--human-readablePrint sizes as 1.2M instead of 1234567.
-n--dry-runShow what would happen without actually copying or deleting anything. Always use before --delete.
--deleteMake the destination an exact mirror. Files removed from source get removed from destination. Destructive.
--exclude=PATSkip files matching PAT (glob). Repeatable. Common: --exclude=node_modules, --exclude='*.log'.
--bwlimit=NCap socket I/O bandwidth (e.g. --bwlimit=10M for 10 MB/s).
--link-dest=DIRHardlink unchanged files against DIR. The standard pattern for space-efficient incremental backups.
-e--rsh=CMDPick the remote shell. Use this to set a custom SSH port: -e 'ssh -p 2222'.

Frequently Asked Questions

What is the rsync command in Linux?
rsync is a Linux command-line utility that copies and synchronizes files between two locations, locally or across machines over SSH. It's preinstalled on most modern Linux distributions and macOS, and is the standard tool for backups, server-to-server file sync, and mirroring directories. The basic syntax is rsync [options] source destination, where either source or destination can be local (a path like /var/www/) or remote (user@host:/path). What sets rsync apart from cp or scp is the delta-transfer algorithm: on subsequent runs, it only sends the parts of files that have changed, which makes large recurring transfers dramatically faster.
What does -avz mean in the rsync command?
-avz is the most common rsync flag combination, especially for transfers over SSH. It stacks three short flags: -a (archive mode, a recursive copy that preserves permissions, modification times, owners, groups, symlinks, and devices), -v (verbose, listing each file as it transfers), and -z (compress data in transit). You'll often see -avzP, which adds --partial and --progress so the transfer is resumable and shows a live progress bar. Skip -z on a fast local network or when copying already-compressed files (videos, JPEGs, .gz), since the CPU cost of compressing incompressible data slows the transfer down.
How do I run rsync over SSH with a custom port?
Pass a custom SSH command to rsync with the -e flag: rsync -avzP -e 'ssh -p 2222' /src/ user@host:/dst/. The quotes are required so the shell passes 'ssh -p 2222' as a single argument. You can also chain additional SSH options the same way, such as a specific identity file: -e 'ssh -p 2222 -i ~/.ssh/backup_key'. Note that rsync's own --port flag is only for the rsync daemon protocol (port 873), not for SSH. For SSH on a non-standard port you always use -e.
How do I exclude multiple directories with rsync?
Repeat the --exclude flag once per pattern: rsync -av --exclude=node_modules --exclude=.git --exclude='*.log' /src/ /dst/. Patterns use glob syntax, and patterns that contain shell metacharacters (* ? [ ]) should be single-quoted so the local shell doesn't expand them first. For a long list, put the patterns in a file (one per line) and use --exclude-from=ignore.txt instead, which is easier to maintain and reuse across scripts. Order matters when you combine --include and --exclude: rsync evaluates rules top-to-bottom and the first match wins.
Why does the trailing slash on the rsync source matter?
A trailing slash on the source changes what gets copied. rsync -av /src/ /dst/ copies the contents of /src into /dst, so you end up with /dst/file1, /dst/file2. rsync -av /src /dst/ (no trailing slash on source) copies the directory itself into /dst, giving you /dst/src/file1, /dst/src/file2. The trailing slash on the destination doesn't change behavior. Only the source side matters. This is the single most common rsync footgun, especially when combined with --delete: a misplaced slash can dump files in the wrong place or empty the wrong directory. Always test with -n (--dry-run) first.

Related Tools

Need to manage SSH connections?

SSH Workbench lets you connect, browse files, and manage servers visually.

Try SSH Workbench Free