Server Management & Access

How can we help?

Guides and technical documentation for your Server4You dedicated server or VPS.

Migration with rsync (Linux)

This guide shows how to move files and complete server content from one Linux server to another with rsync over SSH – without a control panel, directly on the command line.

Prerequisites: SSH access to both servers as root. rsync must be installed on both servers — if it is missing: apt install rsync (Debian/Ubuntu) or dnf install rsync (AlmaLinux/Rocky Linux). Use the same distribution and major version on the target as on the source.

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 --delete \ --exclude=/proc \ --exclude=/sys \ --exclude=/dev \ --exclude=/tmp \ --exclude=/run \ --exclude=/mnt \ --exclude=/media \ --exclude=/lost+found \ --exclude=/boot \ --exclude=/lib/modules \ --exclude=/usr/lib/modules \ --exclude=/etc/fstab \ --exclude=/etc/network \ --exclude=/etc/netplan \ --exclude=/etc/NetworkManager \ --exclude=/etc/sysconfig/network-scripts \ --exclude=/etc/hostname \ --exclude=/var/lib/mysql \ / 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 \ --exclude=/mnt \ --exclude=/media \ --exclude=/lost+found \ --exclude=/boot \ --exclude=/lib/modules \ --exclude=/usr/lib/modules \ --exclude=/etc/fstab \ --exclude=/etc/network \ --exclude=/etc/netplan \ --exclude=/etc/NetworkManager \ --exclude=/etc/sysconfig/network-scripts \ --exclude=/etc/hostname \ --exclude=/var/lib/mysql \ / root@TARGET_SERVER_IP:/

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 \ --exclude=/mnt \ --exclude=/media \ --exclude=/lost+found \ --exclude=/boot \ --exclude=/lib/modules \ --exclude=/usr/lib/modules \ --exclude=/etc/fstab \ --exclude=/etc/network \ --exclude=/etc/netplan \ --exclude=/etc/NetworkManager \ --exclude=/etc/sysconfig/network-scripts \ --exclude=/etc/hostname \ --exclude=/var/lib/mysql \ / 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.