The Basics of Rsync for Everyday Use

The Basics of Rsync for Everyday Use

Rsync, which stands for “remote sync,” is a file synchronization and transfer tool that has been used on Unix-like systems for decades. People still rely on it because it’s fast, reliable, easy to script, and built to move files efficiently, whether you’re copying between folders on one computer or syncing to a remote server.

If you’ve ever pushed code to a server, downloaded a production uploads folder, or made a quick backup, rsync is a tool that quietly gets the job done.

What rsync does

Rsync works by comparing a source and a destination, then transferring only what’s needed to make the destination match the source. This can include:

  • New files
  • Updated files
  • Deleted files (optional, only if you choose this option)
  • File metadata, such as permissions, timestamps, and symlinks, depending on the options you use

It works locally:

  • Folder A → Folder B

It also works remotely, most often over SSH:

  • Your laptop → Your server
  • staging to production (with caution)

Why rsync is fast

Rsync’s main advantage is that it reduces data transfer. Instead of sending whole files each time, it only transfers what has changed. This is especially useful when:

  • A file is large but only slightly edited
  • You’re syncing a lot of files repeatedly (deployments, backups)
  • Bandwidth is limited or latency is high

This works because of the “rsync algorithm,” which uses a delta-transfer method. Simply put, rsync avoids moving data it doesn’t need to.

Rsync can also compress data while transferring. Compression is helpful on slow connections, but on fast networks, it might not be worth the extra CPU usage. You can decide whether to use it based on your needs.

Where rsync runs

  • Linux: Usually available by default or one package install away.
  • macOS: Available (often preinstalled), but many developers install a newer version using a package manager.
  • Windows: Often used through WSL (Windows Subsystem for Linux) or other Unix-like environments.

The flags you’ll see most often

You can do a lot with a few options:

  • -a (archive): Copies folders and files recursively and keeps common metadata (a good default)
  • -v (verbose): Shows what’s happening
  • -h (human-readable): Shows file sizes in a more readable way
  • --progress (or --info=progress2): Transfer progress
  • -z: Compress data during transfer (optional)
  • --dry-run: Show what would happen without changing anything
  • --delete: Removes files from the destination that no longer exist in the source (use with care)
  • --exclude: Skip paths you don’t want to sync

A few quick examples

These examples are simple on purpose, just enough to help you get started.

1) Sync one local directory into another

rsync -avh --progress ./source/ ./destination/

The trailing slash on ./source/ is important. It tells rsync to copy the contents of source into destination. If you leave out the slash (./source), rsync will copy the whole directory into the destination, creating destination/source.

2) Sync a local folder to a remote server over SSH

rsync -avh -e ssh ./local-folder/ user@your-server:/path/to/remote-folder/

This is a common way to deploy code or sync files. SSH takes care of encryption and authentication, while rsync manages the efficient transfer.

3) Preview a sync (and a common “deploy” pattern)

rsync -avh --dry-run --delete ./build/ user@your-server:/var/www/site/
  • --dry-run lets you check the changes before making them.
  • --delete makes the destination match the source by removing files from the destination that aren’t in the source.

Once you’re sure the output is correct, you can remove --dry-run.

Where this fits with WordPress

Rsync is helpful in WordPress workflows because WordPress sites are made up of:

  • Code (themes, plugins, mu-plugins)
  • Content files (uploads)
  • Configuration (wp-config, environment settings)
  • Database (rsync does not handle this directly)

Common rsync uses in a WordPress context:

  • Syncing a theme or plugin directory to staging/production
  • Pulling wp-content/uploads/ down to reproduce a bug locally
  • Keeping the files in a staging environment in sync with a known source

A simple rule that saves trouble: be very careful with --delete, especially when working with uploads/. This option is powerful, but it can remove files you didn’t intend to delete if you use the wrong source or destination.

A good “first habit”

Before you run a new rsync command against anything you care about:

  1. Add --dry-run
  2. Read the output
  3. Confirm the paths are exactly what you think they are
  4. Then run it for real

Keep going

After you’re comfortable with these basics, it’s a good idea to read the rsync manual page:

man rsync

For WordPress sites in particular, tools like rsync shine when paired with a hosting platform that values performance, reliability, and developer-friendly workflows. Our managed hosting for WordPress is built with these principles in mind, giving teams the confidence to deploy, sync, and scale without fighting the infrastructure underneath them.

With a few well-chosen options, rsync can become a safe and repeatable part of your workflow, whether you’re moving WordPress files, deploying a build directory, or keeping backups current.

Chat with Pagely

New Posts in your inbox