Changing VPS providers or upgrading to a fresh OS usually means building a new server and moving your data. This guide shows a reliable way to migrate a Linux VPS to a new server with rsync, keeping downtime to a few minutes.
Before you start
- Root SSH access to both the old and the new VPS.
- A recent backup of the old server.
- Access to your domain's DNS. Lower the TTL of your records to 300 seconds a day before the move.
- If you use a panel-managed VPS platform, check whether it offers built-in migration (for example VirtFusion server migration).
Take an inventory
- Installed services and versions: web server, PHP, database, Node.js, Redis.
- Config files in
/etc(Nginx/Apache vhosts, PHP-FPM pools, cron jobs, systemd units). - Data locations:
/var/www,/home, uploads, Docker volumes. - SSL certificates and how they renew.
- Firewall rules and open ports.
Prepare the new VPS
Follow first steps on a new VPS, then install the same stack (see install a LEMP stack). Prefer reinstalling packages and copying configs over copying whole system directories, especially between different OS versions.
First file sync (old server running)
From the new server, pull files from the old one:
rsync -aHAX --numeric-ids --info=progress2 root@OLD_IP:/var/www/ /var/www/Repeat for other data directories and needed config files (copy configs to a staging folder and review before placing).
Copy databases
Dump on the old server and import on the new one:
ssh root@OLD_IP "mysqldump --all-databases --single-transaction --routines --events" | mysqlFor PostgreSQL use pg_dumpall piped into psql. Test the sites on the new server using your local hosts file pointed at the new IP.
Final sync and cutover
- Put the site in maintenance mode or stop writes on the old server.
- Run rsync again with
--delete(only changes transfer, so it is quick) and re-dump the databases. - Update DNS A/AAAA records to the new IP.
- Issue or copy SSL certificates on the new server.
- Keep the old server running for a few days while DNS propagates and check logs on both.
Troubleshooting
- Permission errors after copy: users may have different UIDs on the new server; create users first or fix with
chown. - Site works by IP but not by domain: DNS not updated yet or cached; check with the IP checker.
- Emails stopped: MX, SPF and reverse DNS still point at the old server.
Frequently asked questions
Can I just copy the whole disk image?
Sometimes, between compatible KVM platforms, but networking, drivers and bootloaders often break. A file-level migration is cleaner.
How long does DNS take?
With a low TTL, most visitors switch within minutes; some resolvers take longer.
Moving a cPanel site instead?
Use migrate a website to cPanel.
