01
Take an inventory of the old server
Anything not written down will be forgotten, and you notice it after cancellation. On the old server, record:
- Running services:
systemctl list-units --type=service --state=running, and open ports with ss -tlnp.
- Sites: the web server configuration files (for example
/etc/nginx/sites-enabled/ or /etc/apache2/sites-enabled/), the site folders and their size (du -sh /var/www/*).
- Versions: PHP, Node.js, MariaDB or MySQL, PostgreSQL. Install the same ones, or versions you know are compatible with your applications.
- Databases and the accounts that access them.
- Scheduled tasks:
crontab -l for each user, and the /etc/cron.d/ folder. The guide scheduled tasks with cron shows where they hide.
- HTTPS certificates, the firewall, authorized SSH keys.
- DNS: every record of your domains, especially MX records if the old server also receives your email. A mail system is migrated separately and needs just as much preparation.
Also note the old server's IP addresses that third parties have allowed (a partner API, a remote database): they will need to accept the new one.
02
Prepare the new server
Install the system, then apply the security settings before copying anything to it: admin account, login with an SSH key, firewall, updates. The guides first steps on a dedicated server and securing a dedicated server give the order to follow.
Then install the software from your inventory (web server, PHP, database) and rsync, which must be present on both machines:
sudo apt update
sudo apt install rsync
Create the same system users as on the old server. Finally, check that the new server can connect to the old one over SSH, or the other way round: that is how the files will travel. If you are not comfortable with SSH, start with connecting over SSH.
03
Copy files with rsync
rsync copies only what has changed: you make a first full copy while the old server is running, then a last, very short one at cutover time. From the new server:
rsync -aHAX --numeric-ids -z --info=progress2 root@old-ip:/var/www/ /var/www/
-a: recursive copy that keeps symbolic links, permissions, timestamps, owner and group;
-H, -A, -X: hard links, ACLs and extended attributes, which -a does not copy;
--numeric-ids: keeps owner numbers instead of mapping them by name; system accounts must then have the same numbers on both sides;
-z: compresses data during the transfer.
The trailing slash matters: /var/www/ copies the folder's contents, /var/www copies the folder itself and adds one more level at the destination. rsync goes over SSH; for an SSH port other than 22, add -e "ssh -p 2222". Owners and groups are only kept if the copy runs as root on both sides; otherwise, fix them afterwards with chown.
For the final copy, add --delete, which removes at the destination what has disappeared at the source. Always test it first with a dry run, -n (--dry-run): a mistyped source with --delete erases files. For a few individual files, SFTP with FileZilla or WinSCP is enough.
04
Transfer the databases
Do not copy the raw files of a running database: export it with its own tool, then import the export.
MariaDB or MySQL. On the old server (with MariaDB, the command is also called mariadb-dump):
mysqldump --single-transaction --routines --events --databases my_db > my_db.sql
--single-transaction gives a consistent export without locking the site, for InnoDB tables; --routines and --events add stored procedures and events, which are not exported by default; --databases includes the database creation. Copy the file with rsync, then, on the new server:
mysql < my_db.sql
mysql -e "CREATE USER 'site'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON my_db.* TO 'site'@'localhost';"
Recreating the application account by hand, as above, avoids importing system tables from another version.
PostgreSQL. pg_dump exports one database at a time, consistently even while it is in use, but not the roles. On the old server:
sudo -u postgres pg_dumpall --globals-only > roles.sql
sudo -u postgres pg_dump -Fc my_db > my_db.dump
On the new one, import the roles first, then the database; the -C option creates it by connecting to the postgres database:
sudo -u postgres psql -f roles.sql
sudo -u postgres pg_restore -C -d postgres my_db.dump
A pg_dump export loads without difficulty into a newer PostgreSQL version; into an older version, it may need manual fixes.
05
Lower the TTL, test and cut over
Lower the TTL in advance. A DNS record's TTL tells resolvers how long to keep it in memory. A few days before, lower it (300 seconds, for example) on the records that will change. Wait at least the length of the old TTL: resolvers that read the old value keep it until it expires. To read the configured value, query one of the zone's name servers: dig example.com A @ns1.your-dns-provider.com.
Test with the hosts file. Before touching DNS, point only your own computer to the new server by adding a line to the /etc/hosts file (Linux, macOS) or C:\Windows\System32\drivers\etc\hosts (Windows, editor opened as administrator):
203.0.113.10 example.com www.example.com
Browse the site, log in, submit a form, check the error logs. For HTTPS, a Let's Encrypt certificate validated over HTTP cannot be obtained while DNS points elsewhere: copy the /etc/letsencrypt folder from the old server with rsync (-a keeps the symbolic links certbot needs). Remove the line from the hosts file after testing.
Cut over. On the chosen day, at a quiet time:
- stop writes on the old server (maintenance mode, or stop the application);
- redo the database exports and the last rsync copy with
--delete;
- import, then change the DNS records to the new address;
- watch traffic arrive in the new server's logs, and check with
dig +short example.com.
Keep an overlap. Leave the old server running for a few days, without writes: it is your way back if a problem appears, and its logs will show whether traffic still arrives. Then set the TTL back to a normal value, keep a full backup of the old server, and only then cancel it.
06
Migrating to a CloudFive dedicated server
Before migrating, check that a dedicated server is justified: the guide VPS or dedicated server helps you decide, and monitoring VPS resources shows what is really saturated. Our dedicated servers:
- are in France, with full root access, delivered in 24 to 72 hours with Debian, Ubuntu, Proxmox or Virtualizor, with Windows (ask about the terms when ordering or by ticket), or with a custom installation on ticket;
- range from the Ryzen 9 9950X, 7950X3D and Ryzen 7 7700, with 2 TB NVMe included, to Intel Core i7 and Xeon, from €75 per month;
- have no commitment and no setup fee: the overlap period does not tie you in.
The move is free for new customers: request it by ticket from the client area, describing the old server and what it hosts (the inventory in the first section is made for this). If you prefer to migrate yourself, the steps in this guide still apply, and support answers your questions during the operation in French 7 days a week, by ticket, on Discord and by phone. If the old server is a CloudFive VPS, cancel it from the client area, manager.cloudfive.fr, once the cutover is complete.
07
Frequently asked questions
How do I migrate a site to a dedicated server without downtime?
Lower the DNS TTL a few days before, copy the files with rsync and the databases with their export tool, test the new server through the hosts file, then run a last sync and change DNS. The only interruption is the short pause in writes during the final copy.
Why lower the TTL before a migration?
The TTL sets how long resolvers keep an address in memory. Lowered in advance, it means the new address is picked up within minutes. It must be lowered at least the length of the old TTL before the cutover.
Which rsync command should I use to migrate a server?
For example rsync -aHAX --numeric-ids -z root@old-ip:/var/www/ /var/www/, run from the new server. Run it again at cutover with --delete, after a dry run with -n. rsync must be installed on both machines.
How do I transfer a MySQL or PostgreSQL database?
For MariaDB or MySQL, export with mysqldump --single-transaction --routines --events and import the file with mysql. For PostgreSQL, export the roles with pg_dumpall --globals-only and the database with pg_dump -Fc, then restore with pg_restore.
Does CloudFive do the migration for me?
Yes, the move is free for new customers: request it by ticket from the client area, describing the old server and what it hosts. If you prefer to do it yourself, follow the steps in this guide; support answers your questions in French, by ticket, on Discord and by phone, 7 days a week.