This content originally appeared on DEV Community and was authored by Rijul Rajesh
When it comes to moving files around in Linux, most people start with cp
or scp
. They work fine, but once you deal with large projects, remote servers, or frequent backups, you start to feel their limits. That is where rsync
comes in.
rsync
is one of those classic tools that every developer eventually encounters. It is fast, reliable, and surprisingly flexible. Whether you want to copy a few files, back up an entire directory, or sync changes across machines, rsync
can handle it with ease.
Let’s walk through what makes it special and how to start using it effectively.
Why rsync is different
The name itself means “remote sync,” and that is the magic. Instead of blindly copying everything, rsync
looks at the source and the destination and transfers only what has changed.
This makes it:
- Efficient: It skips files that are already up to date.
- Fast: It uses a delta algorithm, so only changed parts of a file are sent.
- Reliable: It preserves file permissions, ownership, symbolic links, and more.
Think of it as a smarter cp
that also works over SSH.
The simplest usage
At its most basic, you can use rsync
like cp
:
rsync file.txt backup/
This copies file.txt
into the backup
directory. Simple enough.
Syncing directories
If you want to sync an entire directory:
rsync -av project/ backup/project/
Let’s break this down:
-
-a
means archive mode, which keeps permissions, symbolic links, and timestamps intact. -
-v
means verbose, so you see what is happening.
This command makes sure backup/project/
looks just like project/
.
Syncing over SSH
Here is where it gets powerful. You can sync files to a remote server just as easily:
rsync -av project/ user@server:/home/user/project/
Behind the scenes, rsync
uses SSH for secure communication. No extra configuration is needed as long as you can SSH into the server.
Keeping things tidy
A common trick is the --delete
option:
rsync -av --delete project/ backup/project/
This ensures that if you delete something in the source directory, it also gets removed from the destination. Very useful for true one-to-one syncing.
Dry runs before big changes
Sometimes you want to see what would happen before actually running the command. That is what --dry-run
is for:
rsync -av --dry-run project/ backup/project/
It shows you the actions without making changes. Perfect for testing.
Common real world uses
-
Backups: Automate
rsync
with a cron job and you have a solid backup system. - Deployments: Sync your web app files to a server without re-uploading everything.
- Local file management: Keep two folders in sync without wasting time copying duplicates.
Wrapping up
rsync
is one of those tools that rewards learning. At first, it feels like just another copy command. But once you start using its options, you realize it saves time, bandwidth, and frustration.
If you are setting up backups, moving projects between machines, or deploying code to a server, give rsync
a try. It is simple at the start, yet powerful enough to handle serious workloads.
If you’re a software developer who enjoys exploring different technologies and techniques like this one, check out LiveReview.
LiveReview delivers high-quality feedback on your PRs/MRs within minutes.
It saves hours per review by providing fast, automated first-pass insights. This helps both junior and senior engineers move faster.
If you’re tired of waiting on peer reviews or unsure about the quality of feedback you’ll receive, LiveReview is here to help.
This content originally appeared on DEV Community and was authored by Rijul Rajesh