Migrating Server via rsync
Learn how to transfer your server data to a new server via rsync.
1. What is rsync?
rsync (Remote Sync) is a tool for efficient file transfer and synchronization. It uses a delta transfer algorithm: Instead of transferring files in their entirety, rsync sends only the differences between the source and the destination. This makes it particularly efficient for repeated synchronization runs.
Key features:
- incremental transfer – only changed blocks are transferred
- checksum verification – the integrity of each file is verified
- SSH support – secure transfer over the network
- metadata preservation – permissions, timestamps, symlinks, and ownership are preserved
- dry-run mode (
--dry-run) – simulation without actual changes
2. Preparation
To be on the safe side, create a complete backup before transferring your data.
1. Getting Started
- Log in to the Server Control Panel (SCP).
- Select the source and target servers you want to use for the migration.
- Make sure that the servers is switched off (offline).
- Go to Media > Rescue System.
- Click Activate and OK on the right.
- Make a note of the displayed passwords.
- If the SCP does not automatically restart the servers, restart them manually.
- The servers are being restarted as part of the rescue system.
2. Creating an Inventory of Existing Data
Before the migration, a complete inventory of the source server should be created:
# Overview of disk usage
df -h
# Size of individual directories
du -sh /var /home /etc /opt /srv
Make a note of which services are running, which configuration files are relevant and which databases may need to be handled separately.
3. Ensuring SSH Access
rsync uses SSH for the transfer. Set up password-less SSH access using a key pair beforehand:
# Generate a key pair on the source server (if one does not already exist)
ssh-keygen -t ed25519 -C "server-migration"
# Copy the public key to the target server
ssh-copy-id root@targetserver.example.com
# Test the connection
ssh root@targetserver.example.com "echo Connection successful"
Please note that the SSH key will be lost after the data transfer.
4. Mounting Source Server Hard Drives
Identifying Partitions
To access your operating system's data, you need to mount the partitions containing your data. To find out the names of the partitions, run the following command:
lsblk
Mounting Partitions
The number and names of the partitions vary depending on the configuration and may differ from those listed below.
# Root Partition
mkdir -p /mnt
mount /dev/vda1 /mnt
# Boot Partition
mkdir -p /mnt/boot
mount /dev/vda2 /mnt/boot
# Home Partition
mkdir -p /mnt/home
mount /dev/vda3 /mnt/home
5. Partitioning the Target Server
Partitioning will result in data loss on the hard drive in question!
Partition the target server exactly the same way as the source server, see:
https://www.netcup.com/en/helpcenter/documentation/server/partitioning-kvm-server
Next, mount the partitions exactly as you did on the source server.
3. The rsync Command in Detail
The basic command for moving a server is:
rsync -aHAXvz --progress \
--exclude=/proc \
--exclude=/sys \
--exclude=/dev \
--exclude=/run \
--exclude=/tmp \
/mnt/ root@targetserver.example.com:/mnt/
Overview of the Most Important Options
Option
Meaning
-a
archive mode: recursive, symbolic links, permissions, timestamps, owners
-H
keeps hard links
-A
transfers ACLs (Access Control Lists)
-X
transfers extended attributes (xattrs)
-v
verbose output
-z
compresses during transmission
--progress
shows progress per file
--delete
deletes files in the destination that no longer exist in the source
--dry-run / -n
simulation without changes
--exclude
excludes directories or patterns
4. Procedure
1. Conducting a Dry Run
First, run a test to see what would be transferred:
rsync -aHAXvzn --progress \
--exclude=/proc --exclude=/sys --exclude=/dev \
--exclude=/run --exclude=/tmp \
/mnt/ root@targetserver.example.com:/mnt/
Carefully check the output for any unexpected files or paths.
2. Conducting a First full Synchronization
Start the first transfer. Depending on the amount of data, this process may take several hours. Use screen or tmux so that the process continues even if the connection is interrupted:
screen -S migration
rsync -aHAXvz --progress --delete \
--exclude=/proc --exclude=/sys --exclude=/dev \
--exclude=/run --exclude=/tmp \
--log-file=/root/rsync-migration.log \
/mnt/ root@targetserver.example.com:/mnt/
3. Conducting a Cutover
During the maintenance window, stop all relevant services on the source server and run one final rsync job to transfer the files that have been modified in the meantime:
# Stop services (example)
systemctl stop apache2 mysql nginx
# Final sync
rsync -aHAXvz --progress --delete \
--exclude=/proc --exclude=/sys --exclude=/dev \
--exclude=/run --exclude=/tmp \
--log-file=/root/rsync-migration-final.log \
/mnt/ root@targetserver.example.com:/mnt/
Since most of the data has already been transferred, this run should be completed much faster.
4. Modifying system files on the Target Server
After the data transfer, you must reinstall the bootloader on the target server and adjust /etc/fstab and the network configuration:
# Reinstall the bootloader (if the entire system has been migrated)
grub-install /dev/vda
update-grub
# Check /etc/fstab and adjust UUID entries
blkid
nano /etc/fstab
# Adjust network configuration (IP addresses, hostnames)
hostnamectl set-hostname new-server-name
nano /etc/network/interfaces # or nmcli / netplan depending on the distribution
5. Checking the Function on the Target Server
Start all services on the target server and verify that they are functioning properly:
systemctl start mysql apache2 nginx
systemctl status mysql apache2 nginx
# Check logs
journalctl -xe
tail -f /var/log/nginx/error.log
6. Switching DNS
If all tests are successful, change the DNS record so that it points to the new IP address. Wait for the Time To Live (TTL) to expire so that propagation is complete.
You may also be interested in:
Last update: 1 October 2026
Was this article helpful?