NetworkingIntermediate20 min read

What Is rsync in Networking?

Reviewed byJohnson Ajibi· Senior Network & Security Engineer · MSc IT Security

This page mentions older exam versions. See the Current Exam Context and Legacy Exam Context sections below for the updated mapping.

On This Page

Quick Definition

rsync is a utility that copies and updates files from one place to another. It can work on the same computer or over a network. The smart part is that it only sends the parts of a file that have changed, not the whole file. This makes it very fast for backups and syncing.

Commonly Confused With

rsyncvsscp

scp copies files securely over SSH but does not have delta-transfer capability. It transfers the entire file every time. rsync is more efficient for repeated transfers because it only sends changed parts.

To copy a 1 GB file once, scp is fine. To sync that file daily after small edits, rsync will transfer only the changed blocks, while scp transfers the whole 1 GB each time.

rsyncvscp

cp is a local copy command that works only on the same machine. It does not support remote transfers, delta updates, or preserve extended attributes by default without specific options.

To copy a folder from one drive to another on the same computer, use cp -r. To copy that folder to a server across the internet, use rsync.

rsyncvssftp

sftp is an interactive file transfer protocol over SSH. It is good for manual file browsing and transfers, but it does not have automatic synchronization or delta-transfer capabilities. rsync is better for automated batch syncing.

If you need to upload a single file manually, sftp works. If you need to run a nightly backup of an entire directory tree, rsync is the right tool.

Must Know for Exams

rsync appears in several IT certification exams, particularly those focused on Linux system administration, networking, and data management. For the CompTIA Linux+ (XK0-005) exam, rsync is listed under the file management and data transfer objectives. Candidates are expected to know how to use rsync to synchronize files between systems, understand common options like -a, -v, -z, and --delete, and be able to interpret rsync output for troubleshooting.

Exam questions may ask which command efficiently mirrors a directory from a remote server while preserving permissions and deleting files no longer present at the source. The correct answer would involve rsync -av --delete. For the Red Hat Certified System Administrator (RHCSA) exam, rsync is a standard tool for copying and synchronizing files, and candidates may need to use rsync in a lab environment to set up backups or migrate data.

The LPIC-1 exam has an objective titled 'Perform basic file management' that includes rsync as one of the tools. In the Linux Professional Institute exams, you might see a question about the difference between rsync and scp, or which option allows resuming an interrupted transfer (--partial). For the AWS Certified Solutions Architect – Associate exam, rsync is not a primary objective, but it appears as a best practice for synchronizing data between on-premises servers and AWS storage, such as when using AWS DataSync or rsync over VPN to S3.

In the Cisco CCNA exam, rsync is less directly tested, but understanding data transfer efficiency and network bandwidth usage is relevant. However, for general IT certifications like CompTIA A+ or Network+, rsync may appear in the context of network file transfer protocols and tools. The most targeted exams for rsync are Linux-focused ones.

When studying, pay attention to the difference between local sync, remote sync over SSH, and rsync daemon mode. Also know that rsync uses the SSH protocol by default when you specify user@host, and that the trailing slash in the source path can change the behavior (copying the directory vs. its contents).

These details are frequent exam traps.

Simple Meaning

Imagine you have a big box of Lego bricks at home, and you want to keep an identical box at your friend's house. The first time, you have to bring the whole box over and dump it out. That is like a normal copy.

But what if you only changed a few bricks at home? You would not want to bring the whole box again. Instead, you would just bring the new bricks you added and maybe replace the ones you removed.

That is exactly what rsync does, but for computer files. It looks at the source folder and the destination folder, figures out what is different, and only transfers the differences. It is like a smart shipping service that only sends the updates, not the whole package every time.

This saves a huge amount of time and internet bandwidth, especially when you are working with large files like videos, databases, or system backups. rsync is widely used by system administrators and IT professionals to make sure servers have the same data, to create backups, and to move large amounts of data efficiently. It works both on your local computer and over a network using SSH or its own protocol.

You can use it to mirror entire directories, and it preserves file permissions, timestamps, and ownership if you ask it to. So, rsync is essentially a powerful, intelligent copy tool that makes file synchronization fast and reliable.

Full Technical Definition

rsync is a file transfer and synchronization utility for Unix-like systems, but also available on Windows through Cygwin or WSL. It was originally developed by Andrew Tridgell and Paul Mackerras in 1996. The core innovation of rsync is the delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between source and destination files.

When rsync runs, it first splits the destination file (if it exists) into fixed-size blocks, typically around 700 bytes to 1 kilobyte in size. For each block, it computes two checksums: a weak rolling checksum (based on Adler-32) and a strong MD4 or MD5 hash. These checksums are sent to the source machine.

The source then computes the same checksums for its own file and compares them. Matching blocks are skipped; only non-matching blocks and new blocks are sent. The destination then reconstructs the file using the received blocks and the matched blocks from the original file.

This algorithm is extremely bandwidth-efficient, especially for large files with small changes, such as log files or databases. rsync can operate in two modes: with or without a remote rsync daemon. The most common mode is over SSH, using the -e ssh option, which encrypts the entire transfer.

Alternatively, rsync can use its own daemon protocol on port 873 (TCP), which is faster but unencrypted unless combined with SSH tunneling. The rsync daemon uses a configuration file, typically /etc/rsyncd.conf, to define modules (shared directories) and access controls.

Key command-line options include -a (archive mode, preserves permissions, timestamps, symbolic links, and recursion), -v (verbose), -z (compress during transfer), --delete (remove files at the destination that no longer exist at the source), and --exclude (skip specified files or patterns). rsync is not a full backup solution by itself because it does not version files, but it is often used in combination with snapshot tools like rsync snapshots or as part of backup scripts. In IT environments, rsync is used for remote backups, mirroring websites, distributing configuration files across multiple servers, and syncing data between data centers.

It is a standard tool for any system administrator and appears in many certification exams as a key file transfer utility.

Real-Life Example

Think of rsync like a librarian managing two identical libraries in two different cities. The first time, the librarian needs to send every single book from the main library to the branch library. She packs all the books into boxes and ships them across the country.

That is a full copy, like using cp or scp. Now, after a month, some books have been added, some removed, and a few have corrections, like a new edition of an encyclopedia set. The librarian does not want to ship all the books again.

Instead, she sends a list of all the book titles and their current page counts to the branch. The branch librarian compares that list with her own catalog. She marks which books have the same title and page count, and flags which ones are missing or have different page counts.

Then, she tells the main librarian, 'Only send me the new books, the removed books I will discard, and for the encyclopedia set, just send the updated pages, not the whole book.' That is exactly what rsync does. The main library is the source, the branch is the destination, and the list of checksums is like the catalog comparison.

rsync only transfers the data that is different, making the update much faster and lighter on network traffic. In the IT world, this is how a sysadmin might keep two web servers in sync. Instead of uploading the entire website every time a single CSS file changes, rsync just transfers that one small file.

This saves time, bandwidth, and reduces the chance of errors during large transfers.

Why This Term Matters

rsync matters in practical IT because it is one of the most widely used tools for data synchronization, backup, and migration. In any environment where data needs to be moved or kept in sync across multiple servers, rsync is the go-to solution. For example, when deploying a new application to a load-balanced cluster, you can use rsync to push the updated files to all servers simultaneously while only transferring changed files, minimizing downtime and bandwidth usage.

For backups, rsync is often the core engine behind incremental backup scripts. Instead of doing a full backup every night, which would take hours and fill up storage, rsync only copies files that have changed since the last backup. This makes nightly backups feasible even for terabytes of data.

rsync is also crucial for disaster recovery. If a server fails, restoring from a remote rsync backup is often faster than restoring from tape or a full disk image. rsync preserves file attributes like permissions and ownership, which is critical when restoring system configuration files.

Without rsync, system administrators would have to rely on older tools like FTP or RCP, which do not offer delta transfers and are less secure. rsync also integrates well with cron jobs and automation scripts, making it easy to schedule regular syncs. Even cloud providers and CDN services use rsync internally to distribute content across edge servers.

Understanding rsync is essential for any IT professional who works with Linux servers, storage systems, or data pipelines. It saves time, reduces network load, and is a fundamental skill measured in many certification exams.

How It Appears in Exam Questions

rsync questions in certification exams typically fall into three patterns: scenario-based command selection, configuration and option identification, and troubleshooting. In scenario-based questions, you are given a situation such as a system administrator needs to back up a /var/www directory to a remote server nightly, only transferring changed files, and deleting files at the destination that have been removed from the source. The answer choices will include several rsync commands with different options.

You need to select the one that uses -av --delete and possibly --ssh for remote transfer. Another common scenario is a user wants to resume a large file transfer that was interrupted. You would need to know that the --partial option keeps partially transferred files and allows resumption.

In configuration style questions, you might be asked which daemon configuration file controls access to rsync modules, and the answer is /etc/rsyncd.conf. Or you might be asked which port the rsync daemon listens on, which is TCP 873.

Troubleshooting questions might present an error message like 'rsync: failed to connect to remote host: No route to host' and ask the likely cause, which could be a firewall blocking port 22 (SSH) or port 873 (daemon). Another typical troubleshooting question: a user runs rsync and notices that file permissions are not preserved. The answer is that the -a (archive) option was omitted, since archive mode includes -o and -g for preserving ownership and group.

Questions may also test the difference between rsync and scp. For example, an exam item might ask which tool is more efficient for repeated synchronizations of a large directory. The correct answer is rsync because of its delta transfer capability.

A trap question might describe rsync as a 'backup tool,' but strictly speaking, rsync is a synchronization tool; it does not create versions of files unless combined with a snapshot strategy. Some exams ask about the role of checksums in rsync, and the correct explanation is that rsync uses checksums to identify which blocks of a file have changed, reducing the amount of data transferred.

Practise rsync Questions

Test your understanding with exam-style practice questions.

Practise

Example Scenario

You are an IT support technician for a marketing company. The graphic design team works on large video files stored on a shared server in the main office. You have recently set up a backup server in a remote data center.

Each night, the graphic designers add new video clips and edit existing ones. You need a way to copy only the new or changed files to the backup server, without transferring the entire 500 GB folder every night. You decide to use rsync.

You write a script that runs at 2 AM every day. The command is: rsync -avz --delete /mnt/shared/video/ user@backup-server:/mnt/backup/video/. The -a option preserves all file attributes like permissions and timestamps.

The -v option gives verbose output so you can see what happened. The -z option compresses the data during transfer to save bandwidth. And the --delete option ensures that if a designer deletes a video from the main server, it also gets deleted from the backup server, keeping them in sync.

The first time you run rsync, it transfers all 500 GB because the backup server is empty. That takes a few hours, but after that, each nightly run takes only minutes because most files are unchanged. rsync compares checksums of the files and only transfers the blocks that actually changed.

One night, the internet connection drops during the transfer. When the connection comes back, you run the same command again. rsync resumes from where it stopped because the partially transferred files are kept (using the --partial option that is often enabled by default in modern versions).

This scenario shows how rsync saves time, bandwidth, and hassle compared to doing full copies every time. It also highlights why rsync is a critical tool for backup and synchronization in any organization.

Common Mistakes

Using rsync without any options, just 'rsync source dest'

This performs a basic copy but does not preserve permissions, timestamps, or ownership. It also does not recurse into subdirectories.

Always use the -a (archive) option for typical sync tasks. This includes recursion and preserves metadata.

Forgetting the trailing slash on the source directory path

rsync behaves differently depending on whether the source path ends with a slash. With a trailing slash, it copies the contents of the directory. Without it, it copies the directory itself. This can lead to unintended nested directories.

Know the rule: source with slash copies contents, without slash copies the directory. Use the slash when you want the contents to be placed directly in the destination.

Assuming rsync always works over SSH by default

rsync can use SSH or its own daemon protocol. If you specify a remote host without the -e ssh option, rsync will try to connect to the rsync daemon on port 873, not SSH on port 22.

When you need encrypted transfer over SSH, either include user@host: in the remote path (this automatically invokes SSH) or use the -e ssh option explicitly.

Not using --delete when trying to mirror directories exactly

Without --delete, files that were removed from the source will remain at the destination. The directories will not be exact mirrors.

If the goal is an exact mirror, always include --delete in the rsync command. But be careful because it will delete files at the destination.

Using rsync without understanding that --delete can accidentally wipe data

If you run rsync with --delete but specify the source and destination in the wrong order, you could delete files from the destination unintentionally, potentially losing data.

Always double-check the order: source comes first, destination second. Use the --dry-run option to test the command before running it for real.

Exam Trap — Don't Get Fooled

{"trap":"The question asks which command efficiently syncs a directory from a remote server while preserving permissions and timestamps, and the options include 'rsync -r user@host:/source /dest' and 'rsync -av user@host:/source /dest'. The trap is that -r only copies recursively without preserving metadata, but many learners think -r is enough because they associate 'r' with 'recursive'.","why_learners_choose_it":"Learners see 'recursive' in -r and think that is sufficient for syncing a directory, forgetting that -a (archive) is the standard for preserving permissions, ownership, and timestamps."

,"how_to_avoid_it":"Memorize that the archive option (-a) is actually a combination of options including -rlptgoD (recursive, links, permissions, times, group, owner, devices). For most backup and sync tasks, you must use -a, not just -r."

Step-by-Step Breakdown

1

Invocation

The user types the rsync command with options and paths. For example, rsync -avz source/ user@remote:/dest/. This tells rsync to archive, be verbose, compress, and connect via SSH (because of the user@host syntax).

2

Connection establishment

rsync establishes a connection to the remote host. If using SSH, it authenticates with the user's credentials or SSH keys. If using the rsync daemon, it connects to port 873.

3

File list generation

rsync scans the source directory and generates a list of files, including metadata like size, modification time, and permissions. It sends this list to the destination side.

4

File comparison using checksums

For each file that exists at both source and destination, rsync compares the metadata. If the file sizes or timestamps differ, rsync proceeds to the block-level checksum comparison. The destination splits its file into blocks, computes checksums, and sends them to the source.

5

Delta transfer

The source compares its own file blocks against the checksums received. Blocks that match are skipped. Only the blocks that are different or new are sent to the destination. The destination then reconstructs the file using the matched local blocks and the new blocks from the source.

6

Cleanup and finalization

If the --delete option was specified, rsync removes any files at the destination that are not present in the source. It then updates the destination file metadata to match the source. The transfer is complete, and rsync reports the summary of changes.

Practical Mini-Lesson

rsync is more than just a file copier; it is a sophisticated tool that every system administrator must master. Let us walk through a practical use case: setting up an incremental backup script for a web server. The server has a directory /var/www/html containing the live website.

You want to back it up to a backup server at 2 AM every day. You create a script called backup.sh with the following command: rsync -avz --delete --link-dest=/backup/yesterday /var/www/html/ user@backup-server:/backup/today.

The --link-dest option is a powerful feature that creates hard links to files from a previous backup if they have not changed, saving disk space. The script first renames the previous backup directory, then runs rsync to create the new backup. Only files that changed actually take up new space; unchanged files are just hard links.

This is called a 'snapshot' backup. In practice, you also need to consider bandwidth usage. If the web server has very large files like images or PDFs, add -z for compression to reduce transfer size.

But be aware that compression uses CPU, so on a very busy server, you might skip -z to avoid performance impact. Another real-world consideration: rsync over SSH uses SSH keys for authentication. You should set up passwordless SSH keys to allow the script to run unattended.

A common error is that the user running the script may not have permission to read all files under /var/www/html. Use sudo or adjust file permissions. Also, test the script with --dry-run first to confirm it would not delete anything important.

When troubleshooting, check the rsync exit code: 0 means success, 23 means partial transfer due to error, and others indicate specific problems. Use rsync -v for verbose output to see exactly which files are being transferred. For very large transfers, consider using rsync with --bwlimit to limit bandwidth usage so it does not saturate the network.

Professionals also combine rsync with tools like chron to schedule it, and logrotate to manage log files. Understanding rsync deeply allows you to design robust backup and sync solutions that save time, bandwidth, and storage.

Memory Tip

Remember 'rsync -avz' as 'All Very Zippy', the archive option preserves everything, verbose tells you what happens, and zip compresses data to make it fast.

Covered in These Exams

Current Exam Context

Current exam versions that test this topic — use these objectives when studying.

Legacy Exam Context

Older materials may mention these exam versions, but learners should use the current objectives for their target exam.

XK0-005XK0-006(current version)

Related Glossary Terms

Frequently Asked Questions

What does the -a option in rsync do?

The -a option stands for archive mode. It combines several options: -rlptgoD, which means recursive, preserve symbolic links, preserve permissions, preserve timestamps, preserve group, preserve owner, and preserve device files. It is the standard option for most backup and sync tasks.

Can rsync resume an interrupted transfer?

Yes, rsync can resume interrupted transfers if you use the --partial option. This tells rsync to keep partially transferred files so that when you run the command again, it only transfers the remaining parts instead of starting over. Many modern versions of rsync have --partial enabled by default.

What is the difference between rsync over SSH and using the rsync daemon?

rsync over SSH uses the SSH protocol for transfer and authentication, which is encrypted and secure. The rsync daemon uses its own protocol on port 873 and is faster but unencrypted by default unless you tunnel it over SSH. The daemon requires a configuration file (/etc/rsyncd.conf) and is more suitable for high-speed local network transfers.

Does rsync delete files at the destination by default?

No, rsync does not delete files at the destination unless you explicitly use the --delete option. Without it, files that were removed from the source will remain at the destination, so the two directories will not be exact mirrors.

What does the --dry-run option do in rsync?

The --dry-run option performs a trial run of the rsync command without actually transferring any files. It shows what would be transferred, deleted, or changed. This is very useful for testing commands before running them for real to avoid accidental data loss.

Can rsync copy files between two remote hosts?

Yes, rsync can copy files between two remote hosts, but you typically need to run rsync from one of the remote hosts or use a tunneling technique. The syntax is: rsync user1@host1:/source user2@host2:/dest. This copies files from host1 to host2 via the local machine you are running it on.

Summary

rsync is an essential command-line utility for IT professionals, enabling efficient file synchronization and data transfer between local and remote systems. Its delta-transfer algorithm distinguishes it from older tools like scp or cp, as it only sends the changed parts of files, saving significant bandwidth and time. The -a (archive) option is the most commonly used to preserve file attributes during synchronization, while options like --delete and --partial add precision and resilience to interrupted transfers.

rsync appears in many Linux certification exams, including CompTIA Linux+ and RHCSA, where candidates must know how to construct sync commands, interpret output, and troubleshoot common issues like permission problems or firewall blocks. In real-world IT environments, rsync is a backbone tool for backups, website deployment, server mirroring, and disaster recovery. Understanding how rsync works, from its checksum algorithm to its SSH integration, is critical for any system administrator.

The key takeaway for exam preparation is to practice using rsync with various options, memorize the purpose of -a , -v , -z , --delete , and --dry-run, and be aware of the pitfalls, such as trailing slash behavior and the difference between SSH and daemon modes. With these skills, you will be able to confidently answer exam questions and apply rsync effectively in your career.