Migrate to a new VPS

2 min read07 November 2026

Migrating a VPS is like moving house: the long part is not copying, it is knowing what to take and checking that everything works on arrival. A successful migration keeps the old server intact for several days, lowers the TTL before the switch and tests the new machine before touching DNS.

Starting inventory

List what runs and what depends on what:

Bash
systemctl list-units --type=service --state=running
ss -ltnp
sudo crontab -l
sudo ls /etc/cron.d /etc/systemd/system
dpkg --get-selections > /root/packages.txt

Add what commands do not see: domain names, databases and users, certificates in /etc/letsencrypt, .env files, used ports, external services (SMTP, storage, APIs).

Prepare the target

Install the same major OS version as the source (Debian 13 to Debian 13, for example): configuration paths and packages will match. Create users, add your SSH key, open the firewall, then test the connection before copying data.

Do not copy /etc/machine-id verbatim: two machines with the same identifier confuse journald and some tools. For SSH host keys, copy them only if you want clients to see the same fingerprint; otherwise expect a warning on first connection.

Transfer files and databases

A first pass while the site runs shortens downtime, then a final pass captures the last files.

Bash
sudo apt install rsync
sudo rsync -aHAX --numeric-ids --info=progress2 -e ssh /var/www/ user@YOUR_IPV6:/var/www/

For the database, export with a consistent transaction then import on the target:

Bash
sudo mysqldump --single-transaction --routines --triggers -u root -p app | gzip > app.sql.gz
scp app.sql.gz user@YOUR_IPV6:/root/
gunzip < /root/app.sql.gz | sudo mysql app

On PostgreSQL, use pg_dump -Fc then pg_restore.

Switch DNS

Lower the TTL to 300 seconds at least 24 hours before. Add or change the A and AAAA records to the new address. Test before the switch with a forced resolution:

Bash
curl -6 --resolve "your-domain.tld:443:[YOUR_IPV6]" https://your-domain.tld/

Check the certificate on the new machine, redirects, forms and email delivery. Keep the old server running with its database intact.

Verify and roll back

Watch logs on both sides during the switch. If a serious problem appears, point DNS back to the old address: that is your fastest rollback. Note that data written on the new machine after the switch will not be on the old one; decide quickly or plan replication.

Wait at least 48 hours, take a final backup of the old server, then delete it. Document the inventory, commands and differences between the two machines for the next migration.

Advertisement

Was this article helpful?

Read next