3 min read

Top 10 rsync command examples for 2025

rsync command

Rsync is still one of the most powerful tools for file synchronization in 2025. Whether you’re backing up files, deploying code, or syncing data across servers, these command examples will help you get the job done quickly and reliably.

In this article, you’ll find 10 practical examples, an overview of the most used flags, and tips to use rsync efficiently in real-world scenarios. These examples work on Linux, macOS, and WSL.

What is rsync?

Rsync is a fast and versatile command-line tool for syncing files and directories between two locations. It can copy files locally, over SSH, or even to mounted cloud storage. Thanks to its delta-transfer algorithm, it only copies changed parts of files, making it much faster than traditional copying.

Understanding common rsync flags

Here are the most frequently used flags and what they do:

FlagMeaning
-aArchive mode. Recursively copies files while preserving symbolic links, file permissions, ownerships, and timestamps.
-vVerbose output. Shows the progress of the sync process.
-hHuman-readable output. Formats file sizes in KB, MB, GB instead of raw bytes.
-zCompress file data during the transfer to save bandwidth.
-e sshSpecifies the remote shell to use. Commonly used to enforce SSH for remote syncs.
–deleteDeletes files in the destination that no longer exist in the source. Use with caution.
–excludeSkips files or directories that match the pattern.
–dry-runSimulates a sync without making any changes. Great for testing.

Knowing these flags will help you read and understand the upcoming rsync command examples with confidence.

1. rsync a local directory

rsync -avh ~/projects/ /mnt/backup/projects/

Copies the contents of the projects folder to a backup location, preserving all metadata and showing readable output.

2. rsync to a remote server over SSH

rsync -avz -e ssh ~/website/ user@yourserver.com:/var/www/html/

Transfers files to a remote server over SSH with compression for better speed.

3. Mirror a remote directory locally

rsync -avz user@yourserver.com:/etc/nginx/ ~/server-backups/nginx/

Downloads an exact copy of a remote directory to your local machine. Ideal for backups or audits.


4. Exclude files and folders from sync

rsync -av --exclude "*.log" --exclude "node_modules" ~/app/ /deploy/app/

Skips log files and node_modules folder while copying the app. Useful for deployments.


5. Use compression to speed up transfer

rsync -az ~/videos/ user@yourserver.com:/media/backup/

Adds compression (-z) to speed up transfers, especially over slow connections.


6. Delete files that no longer exist in the source

rsync -av --delete ~/projects/ /mnt/usb/projects/

Makes the destination mirror the source exactly by removing any extra files. Double-check before using this.


7. Dry run to preview changes

rsync -av --dry-run ~/music/ /mnt/music/

Simulates the sync so you can safely verify which files would be affected before running the command for real.

8. Automate daily backups with cron

Open your crontab:

crontab -e

Add:

0 2 * * * rsync -az ~/Documents/ /mnt/backup/

This will back up your Documents folder to an external drive every night at 2 AM.

Want to manage Python environments in your cron jobs? Check out our guide to pip-tools and requirements.txt to streamline your development workflow.

9. Backup with timestamped folders

rsync -av ~/Pictures/ /mnt/drive/pictures-$(date +%F)/

Creates a backup folder with today’s date so you can maintain a history of backups, like pictures-2025-07-10.

10. rsync files larger than a specific size only

rsync -av --min-size=100M ~/downloads/ /mnt/big-files/

This command only syncs files that are at least 100 MB in size from the downloads folder. It’s useful when you want to skip small files and focus on large media, archives, or backups.

Final thoughts

These 10 rsync command examples cover the most practical use cases in 2025, from local backups and cloud deployments to automated nightly syncs. If you’re a developer, sysadmin, or power user, learning how to use rsync effectively will save you hours of time and bandwidth.


To dive deeper, check out resources like the rsync documentation or tools like Grsync for a GUI wrapper.


Previous Post
Stop Using range(len()): Master Python enumerate()

Deploy Django, Flask, and FastAPI in seconds

Seenode simplifies the deployment of your apps with a single, scalable, easy-to-use platform.

Share

Top 10 rsync command examples for 2025

rsync command

Rsync is still one of the most powerful tools for file synchronization in 2025. Whether you’re backing up files, deploying code, or syncing data across servers, these command examples will help you get the job done quickly and reliably.

In this article, you’ll find 10 practical examples, an overview of the most used flags, and tips to use rsync efficiently in real-world scenarios. These examples work on Linux, macOS, and WSL.

What is rsync?

Rsync is a fast and versatile command-line tool for syncing files and directories between two locations. It can copy files locally, over SSH, or even to mounted cloud storage. Thanks to its delta-transfer algorithm, it only copies changed parts of files, making it much faster than traditional copying.

Understanding common rsync flags

Here are the most frequently used flags and what they do:

FlagMeaning
-aArchive mode. Recursively copies files while preserving symbolic links, file permissions, ownerships, and timestamps.
-vVerbose output. Shows the progress of the sync process.
-hHuman-readable output. Formats file sizes in KB, MB, GB instead of raw bytes.
-zCompress file data during the transfer to save bandwidth.
-e sshSpecifies the remote shell to use. Commonly used to enforce SSH for remote syncs.
–deleteDeletes files in the destination that no longer exist in the source. Use with caution.
–excludeSkips files or directories that match the pattern.
–dry-runSimulates a sync without making any changes. Great for testing.

Knowing these flags will help you read and understand the upcoming rsync command examples with confidence.

1. rsync a local directory

rsync -avh ~/projects/ /mnt/backup/projects/

Copies the contents of the projects folder to a backup location, preserving all metadata and showing readable output.

2. rsync to a remote server over SSH

rsync -avz -e ssh ~/website/ user@yourserver.com:/var/www/html/

Transfers files to a remote server over SSH with compression for better speed.

3. Mirror a remote directory locally

rsync -avz user@yourserver.com:/etc/nginx/ ~/server-backups/nginx/

Downloads an exact copy of a remote directory to your local machine. Ideal for backups or audits.


4. Exclude files and folders from sync

rsync -av --exclude "*.log" --exclude "node_modules" ~/app/ /deploy/app/

Skips log files and node_modules folder while copying the app. Useful for deployments.


5. Use compression to speed up transfer

rsync -az ~/videos/ user@yourserver.com:/media/backup/

Adds compression (-z) to speed up transfers, especially over slow connections.


6. Delete files that no longer exist in the source

rsync -av --delete ~/projects/ /mnt/usb/projects/

Makes the destination mirror the source exactly by removing any extra files. Double-check before using this.


7. Dry run to preview changes

rsync -av --dry-run ~/music/ /mnt/music/

Simulates the sync so you can safely verify which files would be affected before running the command for real.

8. Automate daily backups with cron

Open your crontab:

crontab -e

Add:

0 2 * * * rsync -az ~/Documents/ /mnt/backup/

This will back up your Documents folder to an external drive every night at 2 AM.

Want to manage Python environments in your cron jobs? Check out our guide to pip-tools and requirements.txt to streamline your development workflow.

9. Backup with timestamped folders

rsync -av ~/Pictures/ /mnt/drive/pictures-$(date +%F)/

Creates a backup folder with today’s date so you can maintain a history of backups, like pictures-2025-07-10.

10. rsync files larger than a specific size only

rsync -av --min-size=100M ~/downloads/ /mnt/big-files/

This command only syncs files that are at least 100 MB in size from the downloads folder. It’s useful when you want to skip small files and focus on large media, archives, or backups.

Final thoughts

These 10 rsync command examples cover the most practical use cases in 2025, from local backups and cloud deployments to automated nightly syncs. If you’re a developer, sysadmin, or power user, learning how to use rsync effectively will save you hours of time and bandwidth.


To dive deeper, check out resources like the rsync documentation or tools like Grsync for a GUI wrapper.


Previous Post
Stop Using range(len()): Master Python enumerate()

Share