The Basic Command
The form you will use most often copies a folder to a server over SSH:
rsync -avh --progress /var/www/ user@your_server_ip:/var/www/Run it on the machine that holds the source. rsync must be installed on both ends: sudo apt install rsync on Debian and Ubuntu, sudo dnf install rsync on AlmaLinux and Rocky Linux. Over SSH it logs in the way ssh does, with the same keys and the same settings in ~/.ssh/config.
The Options You Need
| Option | What it does |
|---|---|
-a | Archive mode: recursive, keeps permissions, times, and symlinks. |
-v | Lists each file it sends. |
-z | Compresses data in transit. |
-h | Prints sizes in readable units. |
--progress | Shows progress per file. |
-n | Dry run: shows what would change, changes nothing. |
--partial | Keeps a partly sent file so a rerun can continue. |
-P | Short for --partial --progress. |
Archive mode keeps file owners only when rsync runs as root on the receiving side. Otherwise the files belong to the receiving user, and only groups that user is a member of are kept.
Start with a Dry Run
Add -n to any new command before you run it for real:
rsync -avhn /var/www/ user@your_server_ip:/var/www/Nothing is copied. The output lists the files that would be sent. Read it, then run the same command without n.
The Trailing Slash Rule
A slash at the end of the source means "the contents of this folder". Without it, rsync copies the folder itself:
rsync -a /var/www/site/ /srv/copy/ # files of site land in /srv/copy
rsync -a /var/www/site /srv/copy/ # creates /srv/copy/siteThe slash on the source is the one that matters. Getting it wrong is the most common rsync mistake, and the dry run shows it before any file moves.
Mirror a Folder with --delete
Warning first: --delete removes files on the destination that no longer exist in the source. With a wrong path or a missing slash, it can empty the wrong folder. Always run it as a dry run first and read every line that starts with "deleting":
rsync -avhn --delete /var/www/site/ user@your_server_ip:/var/www/site/A mirror also copies your mistakes: a file deleted by accident on the source disappears from the mirror at the next run. A mirror is not a versioned backup on its own.
Use Another SSH Port or Key
rsync -avz -e 'ssh -p 2222' /var/www/ user@your_server_ip:/var/www/
rsync -avz -e 'ssh -p 2222 -i ~/.ssh/backup_key' /var/www/ user@your_server_ip:/var/www/To pull files from the server instead, swap source and destination. A Host entry in your SSH config file saves typing the port and key every time.
Large Files, Slow Links, and Resuming
rsync -avhP --bwlimit=5000 site.tar.gz user@your_server_ip:/srv/backups/--bwlimit caps the transfer rate; a plain number is read in units of 1024 bytes per second, so 5000 is about 5 MB/s. If the connection drops, run the same command again: with --partial (part of -P) rsync continues instead of starting over. Skip -z for files that are already compressed, such as .gz archives or images: it costs CPU and saves nothing.
Simple Snapshots with --link-dest
--link-dest points rsync at the previous copy; unchanged files are hard-linked from there instead of copied, so each dated folder looks complete but only changed files take new space:
rsync -a --delete --link-dest=/srv/backups/2026-11-27/ /var/www/ /srv/backups/2026-11-28/Use an absolute path for --link-dest (a relative one is read from the destination folder), and never edit files inside these folders: a hard-linked file changed in place changes in every dated folder that shares it.
Exclude Files and Fix Common Errors
Caches and temporary files rarely belong in a copy; the patterns are in how to exclude files with rsync.
- rsync: command not found: rsync is missing on the other machine. Install it there.
- Permission denied: the SSH user cannot read the source or write the destination. Copy to a folder that user owns.
- Every file is sent again: times are not kept. Use
-a, which includes-t.
For a single file sent once, scp is quicker to type.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations