Updated: 29 September 2026 · Applies to: rsync 3.2 to 3.5 on AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10, Ubuntu 24.04 and 26.04, Debian 13
rsync copies files and folders, locally or between servers over SSH, and on later runs transfers only what changed. That makes it the standard tool for backups, migrations and keeping two folders in sync. We ran the examples below with rsync 3.4.1 on Debian 13; AlmaLinux 9 and Ubuntu 24.04 ship 3.2.7, and AlmaLinux 10 ships 3.5.
Install
dnf install rsync # AlmaLinux, Rocky Linux, RHEL apt install rsync # Ubuntu, Debian
rsync must be installed on both servers when you copy between them.
The trailing slash matters
rsync -a /src/ /dst/ copies the contents of /src into /dst. Without the slash, rsync -a /src /dst/ creates /dst/src. Most surprises with rsync come from this.
1. Copy a folder locally, keeping permissions and times
rsync -a /var/www/ /backup/www/
-a (archive) copies recursively and keeps permissions, owners, timestamps and symbolic links.
2. Copy to another server over SSH
rsync -a /var/www/ user@203.0.113.20:/var/www/
3. Copy from another server
rsync -a user@203.0.113.20:/home/site/ /home/site/
4. Use a different SSH port or key
rsync -a -e "ssh -p 2222 -i ~/.ssh/backup_key" /data/ user@203.0.113.20:/data/
5. Show progress
rsync -a --info=progress2 /data/ /backup/data/
--info=progress2 shows one line for the whole transfer; -v --progress shows every file.
6. Test first with a dry run
rsync -av --delete --dry-run /data/ /backup/data/
--dry-run (or -n) lists what would be copied and deleted without changing anything. Use it before every command with --delete.
7. Make an exact mirror
rsync -a --delete /data/ /backup/data/
--delete removes files from the destination that no longer exist in the source. A wrong path here can delete data, so run the dry run first.
8. Leave out files and folders
rsync -a --exclude='cache/' --exclude='*.log' /var/www/ /backup/www/
Patterns are relative to the source folder. For many patterns, list them in a file and use --exclude-from=exclude.txt.
9. Compress over slow links
rsync -az /data/ user@203.0.113.20:/data/
-z helps for text over slow connections; it does not help for files that are already compressed (images, videos, archives), and costs CPU on fast networks.
10. Limit the bandwidth
rsync -a --bwlimit=5000 /data/ user@203.0.113.20:/data/
The value is in kilobytes per second: 5000 is about 5 MB/s.
11. Resume large files
rsync -a --partial --info=progress2 bigfile.iso user@203.0.113.20:/srv/
--partial keeps a partly transferred file, so a new run continues instead of starting again.
12. Copy only files up to a size
rsync -a --max-size=100M /data/ /backup/data/
13. Move files (delete them from the source after copying)
rsync -a --remove-source-files /var/log/app/archive/ /backup/logs/
Only files that were copied successfully are removed; empty folders stay.
See what changed
Add -i (--itemize-changes) to see why each file was transferred: a line like >f.st...... means a file was sent because its size and time differed.
For rsync without SSH logins, see how to configure rsync in daemon mode.
Official documentation: rsync manual.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
