Rsync Explained: How Files Are Copied and Kept in Sync

Rsync explained in plain terms means understanding the tool that copies files between computers while sending only the parts that have changed. The central question is how a backup can finish in seconds when the files it protects are enormous, and the answer is that rsync compares the source and the destination first, and transfers only the differences.

Rsync is a command-line program that has shipped with Unix-like systems since 1996, and it remains the standard way to move files between servers, mirror websites, and keep backups up to date. It works over a network or between two folders on the same machine, and it is free, open source, and installed by default on almost every Linux system and Mac.

The tool is famous for one trick, the delta transfer algorithm, which lets it update a large file by sending a fraction of its contents. This article explains what rsync is, how that algorithm works, and where the tool is used.

Key takeaways

  • Rsync copies files and keeps two locations in sync.
  • It transfers only the parts of a file that have changed.
  • It works over SSH, so transfers are encrypted.
  • It can delete files at the destination that no longer exist at the source.
  • It is the standard tool for backups, mirroring, and deployment.

What rsync is

Rsync is a file synchronisation and transfer program for Unix-like systems, first released in 1996 by Andrew Tridgell and Paul Mackerras. Its name is short for remote sync, and its job is to make one set of files match another, whether the two sets are on the same computer, on two machines in the same office, or on servers on opposite sides of the world.

The basic command names a source and a destination, and rsync works out what needs to happen. Files that are missing at the destination are copied in full, files that have changed are updated, and files that are already identical are left alone. That comparison is what makes rsync fast: a second run over the same files finishes almost immediately, because there is nothing new to send.

Rsync normally runs over SSH, the secure shell, which means the transfer is encrypted and authenticated with the same keys and passwords used for logging in to a server. It can also run as its own daemon, serving files to anyone who connects, which is how public software mirrors distribute their files. Our guide to Linux explains the operating system rsync ships with, and our guide to data backup explains the wider practice that rsync is most often used for.

How rsync works

The process starts with a comparison. Rsync lists the files at the source and the destination, and for each file it checks the size and the modification time. If both match, the file is assumed to be unchanged and is skipped. A checksum comparison can be requested instead, which reads both copies fully and compares their contents, at the cost of more work on both machines.

For a file that has changed, rsync uses its delta transfer algorithm. The destination splits its copy of the file into fixed-size blocks and sends a checksum of each block to the source. The source then searches its own copy for matching blocks, and sends only the data that does not match, together with instructions for reassembling the file from the old blocks and the new data.

The result is that a small change to a large file costs almost nothing to transfer. Editing a single line in a ten-gigabyte database dump, for example, sends only the changed blocks, not the whole dump, which is why rsync is practical over slow connections where a full copy would take hours.

Options control the details. The archive mode, written as -a, preserves permissions, ownership, timestamps, and links, so the copy is a faithful replica rather than just the same contents. The –delete option removes files at the destination that no longer exist at the source, which is what turns a copy into a true mirror, and the –dry-run option shows what would happen without changing anything.

Compression can be added with the -z option, which compresses the data in transit and helps on slow networks, though it adds work for the processors on both ends. Progress can be watched with –progress, which shows each file as it transfers, and transfers can be resumed after an interruption, since rsync simply compares again and continues where it left off.

A laptop on a dark desk with its screen showing a glowing green file transfer with only changed blocks highlighted
A laptop showing a glowing green file transfer with only changed blocks highlighted shows how rsync works: comparing first, then sending only the differences.

Comparing rsync with other ways to copy files

Rsync is one of several ways to move files between machines. Simple copy tools move everything every time, cloud storage syncs through a provider’s servers, and secure copy sends whole files over SSH, but each suits a different need.

The table below sets out the main contrasts between the leading approaches.

Aspect Rsync Secure copy Cloud sync
Changed files Sends only differences Sends the whole file Sends only differences
Needs a server No, runs over SSH No, runs over SSH Yes, the provider’s servers
Preserves details Yes, permissions and times Mostly, with options Often not fully
Delete extra files Yes, with –delete No Yes, usually
Best for Backups and mirroring Quick one-off copies Sharing between people

The practical result is that rsync is the right tool for repeated transfers between machines you control, secure copy is the quick choice for a single file, and cloud sync is the convenient choice when several people need the same files.

Where rsync is used

Backups are the largest use. A nightly rsync job copies a server’s files to another machine, and because only the day’s changes are sent, the backup finishes quickly and uses little bandwidth. Keeping several dated copies, or combining rsync with hard links so unchanged files are shared between backups, gives a full history without storing the same data many times.

Website deployment uses rsync heavily. A developer builds a site on their own machine, then rsyncs the changed files to the web server, which is faster and safer than uploading everything or logging in to edit files by hand. Static sites, documentation, and small applications are all commonly deployed this way.

Software mirrors depend on rsync. The public servers that distribute Linux distributions, packages, and updates sync from each other with rsync, often several times a day, so that a user downloading software gets it from a nearby mirror rather than the single original server.

Migration is another common use. Moving a website, a mailbox, or a whole server to new hardware usually means running rsync repeatedly: once for the bulk of the data, then again for the changes since, until the final switch-over needs only a short pause. The same technique moves data between cloud providers.

Home users use rsync too, often without knowing it, since many backup programs for Linux and Mac are built on top of it. A scheduled job that mirrors a photo library to an external drive, or a home server to a second disk, is usually rsync underneath a friendly interface.

Strengths and limits

The greatest strength of rsync is efficiency. By sending only what changed, it makes large transfers practical over ordinary connections, and by resuming cleanly after an interruption, it turns an unreliable network from a problem into an inconvenience. The tool has been refined for nearly thirty years, and its behaviour is well understood.

It is also a strength that rsync is a single, self-contained program with no server to install and no account to create. If you can log in to a machine over SSH, you can rsync to it, which is why it works everywhere from a home network to a data centre.

The limits are real, though. Rsync is a command-line tool, and its many options take time to learn, with mistakes that can delete data, notably a –delete pointed at the wrong directory. It has no built-in scheduling, no graphical progress beyond a text display, and no version history of its own, so keeping old versions needs a wrapper or a separate tool.

Rsync checklist

  • Test with –dry-run first, so you see what would change before it changes.
  • Use archive mode (-a) to preserve permissions, times, and links.
  • Remember the trailing slash: it decides whether the folder itself or only its contents are copied.
  • Add –delete only when you genuinely want a mirror, and check the direction first.
  • Use –progress on large transfers so you can see what is happening.
  • Run over SSH with key authentication for unattended jobs.
  • Exclude caches and temporary files with –exclude to save time and space.
  • Keep logs of scheduled rsync jobs, so a failed backup is noticed.
  • Verify a backup by restoring from it occasionally, not just by trusting the log.

Frequently asked questions

What is rsync in simple terms?

Rsync is a tool that copies files between computers and keeps two locations in sync. It compares the source and destination first, then transfers only the parts that have changed.

What is the difference between rsync and secure copy?

Secure copy sends whole files every time, while rsync sends only the differences, which makes repeated transfers much faster. Rsync can also delete files that no longer exist at the source, turning a copy into a mirror.

Does rsync work on Windows?

Rsync is a Unix tool, but it runs on Windows through the Windows Subsystem for Linux, through Cygwin, or through ports built for Windows. Most Windows users instead use backup software that includes similar features.

What does the trailing slash mean in rsync?

It decides what is copied. A source written as “photos/” copies the contents of the folder, while “photos” without the slash copies the folder itself. Getting it wrong creates an extra level of folders.

Can rsync resume an interrupted transfer?

Yes. Running the same command again compares the two sides and continues where the transfer stopped, sending only what is still missing. This is one of its most useful properties on unreliable connections.

Is rsync secure?

Yes, when run over SSH, which encrypts the transfer and checks the identity of both machines. Rsync itself adds no security, so it should not be used over an unencrypted connection for sensitive data.

The bottom line

Rsync explained in one line is this: a tool that keeps two sets of files identical by comparing them first and sending only the differences.

It is old, plain, and text-based, yet it remains the backbone of backups, mirroring, and deployment on Unix-like systems, because the problem it solves has not changed: moving files is easy, but moving only what changed is what makes it fast.

This article is general information about how rsync works, not advice about backing up or transferring files for a particular system.

Latest articles

Scroll to Top