Migration with rsync (Linux)

With rsync you can securely and efficiently transfer files, directories, and complete server content over SSH from one Linux server to another — no control panel required, directly from the command line.

Prerequisites: SSH access to both servers as root. rsync is pre-installed on most Linux distributions — if not: apt install rsync or yum install rsync.

rsync flags for migration

FlagPurpose
-aArchive mode — preserves permissions, ownership, symlinks, and timestamps
-vVerbose — shows which files are being transferred
-zCompress during transfer — saves bandwidth
--progressShows progress per file
--deleteDeletes files on the target that no longer exist on the source — for a clean sync
--excludeExcludes directories or file patterns from the transfer

Step 1: Set up SSH between servers

Copy your SSH key from the source server to the target for passwordless access.

Run this on the source server — replace the IP with the target server's address:

Terminal
ssh-keygen -t ed25519 -C "migration" ssh-copy-id root@TARGET_SERVER_IP

Step 2: Run a dry run

Use --dry-run to preview what would be transferred without moving any data.
Terminal
rsync -avz --dry-run --exclude=/proc --exclude=/sys --exclude=/dev --exclude=/tmp / root@TARGET_SERVER_IP:/

Review the output for unexpected files or errors before starting the real transfer.

Step 3: Start the full transfer

Transfer all data from the source to the target server.

Run the actual transfer — ideally inside a screen or tmux session so it continues if the SSH connection drops:

Terminal
screen -S migration rsync -avz --progress --delete --exclude=/proc --exclude=/sys --exclude=/dev --exclude=/tmp --exclude=/run / root@TARGET_SERVER_IP:/

Do not stop active services on the source server during the transfer — active database files should be transferred separately via Database Migration.

Step 4: Delta sync before switching

Run a second sync just before the DNS cutover to catch any changes made since the first run.
Terminal
rsync -avz --progress --delete --exclude=/proc --exclude=/sys --exclude=/dev --exclude=/tmp --exclude=/run / root@TARGET_SERVER_IP:/

Step 5: Start services & test

Start the web server, database, and other services on the target and verify everything before switching DNS.
1.Start all services on the target server (systemctl start nginx, systemctl start mysql, etc.)
2.Test your applications via the target server's IP address
3.Update your DNS records to point to the new IP once everything works correctly

Further Documentation

For the full reference of all rsync options, refer to the official documentation.