Skip to content
-
Subscribe to our newsletter & never miss our best posts. Subscribe Now!
The Server Admin
The Server Admin
  • Home
  • Linux
  • Windows
  • About
  • What Powers The Server Admin
  • Home
  • Linux
  • Windows
  • About
  • What Powers The Server Admin
Close

Search

  • https://www.facebook.com/
  • https://twitter.com/
  • https://t.me/
  • https://www.instagram.com/
  • https://youtube.com/
Subscribe
Linux

Rsync Command Examples

By Anthony
February 10, 2026 2 Min Read
0

rsync is a powerful, efficient tool for copying files and directories — and it’s especially useful for transferring files between locations (like across different machines or storage systems) while preserving permissions, timestamps, and even handling large files with minimal overhead.


✅ Basic Syntax

rsync [OPTIONS] SOURCE DESTINATION

🎯 Example: Transfer One File from Location A to Location B

Let’s say:

  • Your file is at /home/user/old_folder/myfile.txt
  • You want to copy it to /mnt/backup/myfile.txt

➤ Simple Copy (Preserves all metadata)

rsync /home/user/old_folder/myfile.txt /mnt/backup/

This copies myfile.txt to /mnt/backup/ — if the destination folder doesn’t exist, rsync will create it.


🧩 Useful Options

1. --progress — Show progress during transfer

rsync --progress /home/user/old_folder/myfile.txt /mnt/backup/

2. --delete — Delete files in destination that don’t exist on source (useful for syncing)

⚠️ Not recommended for one-time transfers unless you’re doing a sync.

rsync --progress --delete /home/user/old_folder/myfile.txt /mnt/backup/

3. --no-preserve — Don’t preserve permissions, timestamps, etc. (rarely needed)

rsync --no-preserve /home/user/old_folder/myfile.txt /mnt/backup/

4. --backup / --backup-dir — Create backup copies (optional)

Use this if you want to keep a copy of the original file before overwriting.

rsync --backup --backup-dir=/mnt/backup.bak/ /home/user/old_folder/myfile.txt /mnt/backup/

🌐 Transfer Between Machines (SSH)

If you’re transferring over SSH (common use case):

rsync -avz -e "ssh -p 22" /home/user/old_folder/myfile.txt user@remote-host:/path/to/destination/

Breakdown:

  • -a — archive mode (preserves permissions, timestamps, symlinks, etc.)
  • -v — verbose output
  • -z — compress data during transfer
  • -e "ssh -p 22" — specify SSH connection (replace 22 with port if needed)
  • user@remote-host — target machine
  • /path/to/destination/ — destination path on remote machine

💡 Tip: Use rsync -avz for most cases — it’s the “default” good option for file transfers.


📌 Summary: Quick Commands

PurposeCommand
Simple copyrsync /source/file.txt /destination/
Copy with progressrsync --progress /source/file.txt /destination/
Copy via SSHrsync -avz -e "ssh -p 22" /source/file.txt user@host:/destination/
Copy with backuprsync --backup --backup-dir=/backup/ /source/file.txt /destination/

🚫 Common Mistakes

  • ❌ rsync file.txt destination/ — Wrong! You must specify the full source path.
  • ❌ rsync -r file.txt — rsync doesn’t work with single files like that. Use rsync file.txt destination/.
  • ❌ rsync -r /path/ — rsync doesn’t copy directories unless you specify the file inside.

✅ Bonus: Check if rsync is installed

which rsync

If you don’t see it, install it:

  • Ubuntu/Debian:
  sudo apt update && sudo apt install rsync
  • CentOS/RHEL/Fedora:
  sudo yum install rsync   # CentOS/RHEL
  sudo dnf install rsync    # Fedora

🚀 Created with my self hosted AI. 1st one as well!

Author

Anthony

Follow Me
Other Articles
Previous

How to restrict sftp user to read-only access

Next

Robocopy Examples

Search

Need a Virtual Server for sysctl testing? Check out our plans!

Popular Posts

  • Mount sFTP folder as local drive
    by Anthony
    June 9, 2026
  • Robocopy Examples
    by Anthony
    February 12, 2026
  • Rsync Command Examples
    by Anthony
    February 10, 2026

Trending

  • Mount sFTP folder as local drive
    by Anthony
    June 9, 2026
  • Adding a GUI to a Server or VPS
    by Anthony
    August 27, 2024
  • Back up to a shared folder with Time Machine on Mac
    by Anthony
    January 4, 2025
  • Backup Your Databases
    by Anthony
    March 24, 2024

Editors Picks

    Send an email:
    mail@example.com

    Call me:
    123-456-7890

    • Facebook
    • Twitter
    • Instagram
    • TikTok
    • LinkedIn
    • Behance
    Copyright 2026 — The Server Admin. All rights reserved. Blogsy WordPress Theme