What Is rsync?

Category: FTP & File Management ยท Updated 2026-11-05

rsync is a command-line utility for copying and synchronizing files and directories, locally or over a network, that only transfers the parts of a file that have changed instead of the whole file each time. This makes repeated backups and updates much faster than plain copying, especially over SSH to a remote server.

How rsync works

On the first run, rsync copies everything, just like any file copy tool. On later runs, it compares the source and destination using file size and modification time, and for files that exist on both sides it uses a delta-transfer algorithm to send only the changed blocks rather than the entire file. This makes it efficient for large websites, backups and media libraries that change only partially between runs.

rsync can copy over a local filesystem, over SSH to a remote server, or using its own daemon protocol (rsync://). For website and server backups, syncing over SSH is the most common setup because it reuses existing SSH credentials and is encrypted in transit.

Common rsync commands

# Copy a local folder, preserving permissions and timestamps
rsync -av /var/www/site/ /backup/site/

# Sync to a remote server over SSH
rsync -avz -e ssh /var/www/site/ user@203.0.113.10:/backup/site/

# Preview changes without copying anything (dry run)
rsync -avzn /var/www/site/ user@203.0.113.10:/backup/site/

# Mirror a folder and delete files removed from the source
rsync -av --delete /var/www/site/ /backup/site/
FlagMeaning
-aArchive mode: preserves permissions, timestamps, symlinks and ownership
-vVerbose output, lists files as they transfer
-zCompresses data during transfer, useful on slower links
-nDry run, shows what would happen without changing anything
--deleteRemoves files at the destination that no longer exist at the source

The trailing slash matters

A trailing slash on the source path changes the result. rsync -av /var/www/site /backup/ creates a site folder inside /backup/, while rsync -av /var/www/site/ /backup/ copies the contents of site directly into /backup/ without an extra folder level. Mixing this up is a common source of confusing duplicate paths.

Typical uses in web hosting

  • Pulling a nightly backup of website files from a server to local or offsite storage.
  • Migrating a site between two hosts while keeping file ownership and permissions intact.
  • Syncing a staging environment with production files before testing.
  • Mirroring uploads or media folders between a primary and a failover server.

Because rsync preserves permissions and only sends differences, it is also commonly scheduled with cron for recurring, low-bandwidth backups.

Frequently asked questions

What does rsync stand for?

rsync stands for "remote sync." It is named for its original purpose of synchronizing files between a local machine and a remote one efficiently.

Is rsync the same as scp?

No. scp simply copies files from one place to another every time, while rsync compares source and destination first and transfers only the differences, which makes repeated syncs much faster.

Does rsync work over SSH?

Yes, and it is the most common way to run it for website backups. Adding the SSH protocol (for example <code>rsync -avz -e ssh source user@host:/destination</code>) encrypts the transfer using the server's existing SSH access.

What does the --delete flag do in rsync?

It removes files from the destination that no longer exist in the source, which turns a one-way sync into a true mirror. Without it, rsync only adds and updates files and never deletes anything on its own.

Is rsync available on Windows?

Not natively, but it can be used through WSL (Windows Subsystem for Linux), Cygwin, or a dedicated Windows build. On Linux and macOS, rsync is usually installed by default or available through the system package manager.

Can rsync be used for scheduled backups?

Yes, rsync is commonly paired with cron to run nightly or hourly backups automatically, since each run after the first only transfers what has changed and keeps the job fast.

Related topics