NEW! EPYC + NVMe based VPS

Log in
+1 (855) 311-1555

Rsync for Linux: How to sync, copy, and back up files like a pro

5 min read - May 24, 2025

hero image

Table of contents

  • Rsync for Linux: How to sync, copy, and back up files like a pro
  • What is rsync?
  • Why rsync is great
  • Common rsync options explained
  • Rsync examples
  • Copy a directory locally
  • Sync to a remote server over SSH
  • Dry run to see what will be copied
  • Backup a remote server to your local machine
  • Mirror two directories
  • Exclude specific files or folders
  • Rsync over cron: Automated backups
  • Video recommendation
  • Final thoughts

Share

Learn how to use rsync on Linux to sync files, copy data between servers, and automate backups. This powerful command-line tool is essential for developers and sysadmins.

Rsync for Linux: How to sync, copy, and back up files like a pro

Rsync is one of the most efficient and reliable file transfer tools available on Unix-like systems. Whether you're syncing servers, copying backups, or migrating between VPS providers, rsync is often the smartest tool for the job.

This post breaks down what rsync does, why it’s better than basic copy tools, and how to use it with confidence.


What is rsync?

Rsync is a command-line tool for syncing files and directories between two locations. It can work:

  • Locally: copying from one directory to another on the same machine
  • Over SSH: copying from one system to another securely
  • With resume support: it skips unchanged files and resumes partial transfers
  • With compression: it reduces transfer time over slow links

Unlike scp or cp, rsync compares source and destination, only sending differences — which makes it incredibly bandwidth- and time-efficient.


Why rsync is great

  • Fast incremental transfers – only changed data is sent
  • Preserves permissions, symlinks, timestamps – ideal for system-level tasks
  • Robust over SSH – secure and script-friendly
  • Dry-run mode – see what will change before running anything
  • Compression support – speeds up slow transfers (-z flag)
  • Network-friendly – resume broken transfers without restarting

Common rsync options explained

Here are the most useful flags you'll use:

  • -a → archive mode (preserves ownership, permissions, symbolic links, etc.)
  • -v → verbose (shows what’s happening)
  • -z → compress file data during the transfer
  • --progress → show live progress updates
  • --delete → delete files on the destination that don’t exist on the source
  • -e ssh → use SSH for remote connections

Rsync examples

1. Copy a directory locally

rsync -av /source/path/ /destination/path/

This copies everything in /source/path/ into /destination/path/, preserving metadata.


2. Sync to a remote server over SSH

rsync -avz /local/dir/ user@remote_ip:/remote/dir/

The -z adds compression; the -e ssh part is implicit when using a remote host.


3. Dry run to see what will be copied

rsync -avz --dry-run /local/dir/ user@remote:/dir/

Great for testing before syncing anything — nothing is actually copied.


4. Backup a remote server to your local machine

rsync -avz user@remote_ip:/etc/ /backup/etc/

Use this to create a local snapshot of remote config files.


5. Mirror two directories

rsync -av --delete /source/ /destination/

This ensures that the destination matches the source — including deletions.


6. Exclude specific files or folders

rsync -av --exclude="*.log" /src/ /dest/

Skip all .log files in this example.


Rsync over cron: Automated backups

Want daily server config backups?

  1. Create a script like:
    rsync -az /etc/ user@backup:/home/backups/hostname/etc/

  2. Add to your crontab with crontab -e:
    0 2 * * * /home/youruser/rsync-backup.sh

This runs the job every night at 2:00am.


Video recommendation

Title: Master Rsync! The Ultimate Linux File Syncing Guide!
Channel: Tech Simplified
Master Rsync! The Ultimate Linux File Syncing Guide!


Final thoughts

Rsync is one of those tools that becomes indispensable once you understand it. It’s reliable, efficient, and battle-tested — perfect for everything from simple file copies to full system migrations.

Whether you're managing a single VPS or a fleet of servers, learning to use rsync well will save you time, bandwidth, and stress. Why not try it out on our high performance VPS? You can get started for just $6.99.

Blog

Featured this week

More articles
Digital eye strain: How to protect your vision in a screen-heavy world

Digital eye strain: How to protect your vision in a screen-heavy world

Staring at screens all day? Learn how to reduce digital eye strain with proven techniques and tools. This guide is essential for remote workers, developers, and anyone in tech.

4 min read - May 21, 2025

#vps

How to load balance a website with NGINX and multi-location VPS Hosting

5 min read - May 20, 2025

More articles
background image

Have questions or need a custom solution?

icon

Flexible options

icon

Global reach

icon

Instant deployment

icon

Flexible options

icon

Global reach

icon

Instant deployment