How to migrate a Debian server (with rsync)

This is a guide to clone a Debian server from a dedicated machine to another one. It is using rsync.


I've been running a dedicated server (a Dedibox SC) for 6 years, it's been successfully serving my websites, emails and a few other services. Today, I needed to migrate it a newer machine (still a Dedibox: Dedibox SC 2016).

Specifications of the two servers:

Both machines are running the same CPU architecture (x86_64) (this is important for the migration process). The new machine runs a newer version of the CPU, so more instruction sets are supported (it prevents running into the problem of binaries compiled for different instruction sets).

I didn't want to manually replicate all my configurations and crons from one machine to another, so I chose the easiest way: Cloning the existing server to another machine (using rsync).

I am going to use rescue mode as it gives me the guarantee that the original files won't be modified while being transferred (so I won't have to deal with corrupted files - like MySQL databases which could be corrupted during the transfer otherwise).

You could probably do it on a running server if you want to reduce the downtime, in this case do a first rsync pass (long) and when it's done shutdown all your services (especially MySQL) and do another rsync pass (it'll only copy the files that have been modified in between the two runs - which should be pretty fast).

Some steps are specific to using a Dedibox (I'll mark these steps), feel free to skip or adapt them.


Cloning instructions (rsync)

I am going to refer to the source server as the old server and to the destination server as the new server.

Feel free to adapt or skip the steps marked [Dedibox specific].

Install a fresh Debian into your new server

Prepare your old server

We're going to copy the file in offline mode to prevent them to be modified while being transfered.

Prepare your new server

We're going to prepare your new server to receive the copied files.

Wait for a while until it's done...

If you get disconnected you can still reconnect to your new server and type screen -r.

Configure your new server

Now you need to change the migrated configuration to match the hardware of your new server.

Once rsyncing has completed:

Install grub on your new server

Once rsyncing and editing configuration files is done, setup grub on your new machine:

(At this point, your root filesystem and boot filesystem should still be mounted into /mnt/new_server and /mnt/new_server/boot)

Reboot your new server and test

Now you're ready to test if your new system behaves properly:

If everything works, then you can edit your old DNS to point to your new server's ip. The update usually takes up to 24 hours for the changes to propagate properly.

Once your DNS are updated and propagated (usually the next day), you can test again that all your services are working properly.

You should probably shutdown your old server at this point to prevent clients from connecting to your old server. Depending on how your services are configured, this will prevent you from getting data inconsistencies where new emails arrive on your old server or new user accounts are being created on your old database (remember that DNS propagation can take time).

For Dedibox users: You can also update your reverse DNS from the console and enable your ftp backup space if you want (just remember to update your crons / backup scripts to point to your new ftp host / username / password combination).


If after a few minutes you still can't ssh into your new server, here are a few steps so you can try to figure out what is going on:


Here are more websites if you run into troubles and want to read more about the various methods: