How to Transfer Files Between Servers Using rsync
When you need to move files between two servers — migrating a site, shipping backups off-box, keeping a mirror in sync — rsync is the tool professionals reach for. It copies only what has changed, resumes if interrupted, and runs securely over SSH. Once you know the basic pattern, it saves enormous time.
You will need SSH access to both servers.
The basic command
To copy a folder from your current server to a remote one:
rsync -avz /local/path/ user@remote-server:/remote/path/
The flags matter: a preserves permissions and timestamps, v is verbose so you see progress, and z compresses in transit to save bandwidth.
Watch the trailing slash
A trailing slash on the source (/local/path/) copies the contents of the folder. Without it (/local/path), it copies the folder itself into the destination. This one detail causes most rsync surprises, so decide which you want.
Resuming and previewing
- Preview first with
--dry-runto see what would happen without moving anything. - Show progress on large transfers with
--progress. - Resume a broken transfer by simply running the same command again — rsync picks up where it left off.
A real migration example
Moving a website's files to a new server, previewing first:
rsync -avz --progress --dry-run /home/user/public_html/ user@newserver:/home/user/public_html/
Happy with the preview? Remove --dry-run and run it for real. For the database side of a migration, see exporting and importing a database. Prefer we handle the whole move? See requesting a website migration.
Frequently asked questions
rsync or scp — what is the difference?
scp is a straight copy; rsync is smarter — it transfers only differences and can resume. For anything large or repeated, rsync wins comfortably.
It keeps asking for a password.
Set up SSH key authentication between the servers and rsync will run without prompting, which is essential for scheduled or scripted transfers.
Can I schedule an automatic sync?
Yes — put your rsync command in a cron job (with SSH keys in place) to keep a backup mirror updated automatically.
Was this article helpful?