
How to Migrate a Website to a New VPS with Zero Downtime (2027)
How to Migrate a Website to a New VPS (Zero Downtime)
Moving your website to a new VPS feels risky – one wrong step and your site goes dark. But here’s the secret professionals use: you don’t switch anything until the new server is already working perfectly. Follow this process and your visitors will never notice the move.
What You’ll Need
- SSH access to both the old and new server
- A full backup of your files and database
- Access to your DNS management (registrar or Cloudflare)
- About 1-2 hours of quiet, focused time
Step 1: Set Up the New Server First
Install your stack (or a panel like CloudPanel) on the new VPS and create an empty site matching your domain. Don’t change DNS yet – the old server keeps serving visitors throughout.
Step 2: Backup Files and Database on the Old Server
Compress your website files:
tar -czvf site-backup.tar.gz /var/www/yourdomainExport the database:
mysqldump -u root -p your_database > db-backup.sqlAlways verify the backup file size isn’t suspiciously small – a 2 KB database dump means something failed.
Step 3: Transfer Everything to the New VPS
Send files directly server-to-server with rsync (faster than downloading to your PC):
rsync -avz -e ssh root@old-server-ip:/root/site-backup.tar.gz /root/Then extract the files into the new site’s web root and import the database:
mysql -u root -p new_database < db-backup.sqlUpdate your wp-config.php (or app config) with the new database credentials.
Step 4: Test Before Switching (The Zero-Downtime Trick)
This is the step everyone skips – and regrets. Preview the site on the new server before the world sees it by editing your computer’s hosts file:
new-server-ip yourdomain.comNow your browser loads the site from the new VPS while everyone else still sees the old one. Click through pages, test logins, forms, and checkout. Fix file permissions if images break (chown -R www-data:www-data is a common cure). Only continue when everything works.
Step 5: Lower TTL, Then Switch DNS
A day before migrating, lower your DNS TTL to 300 seconds (5 minutes) so the change propagates fast. Then update your A record to point to the new server IP.
Remove the hosts-file entry from your computer, and monitor as traffic shifts to the new server over the next few hours.
Step 6: Keep the Old Server Running for 48-72 Hours
Don’t cancel the old server immediately. Some DNS resolvers are slow, and emails or orders could still land there. After 2-3 days of zero traffic on the old server, take a final backup and shut it down.
Common Migration Mistakes
- ❌ Switching DNS before testing the new server
- ❌ Forgetting to lower TTL in advance
- ❌ Cancelling the old hosting the same day
- ❌ Forgetting cron jobs, email accounts, or SSL certificates
- ❌ Not reissuing Let’s Encrypt SSL on the new server
Final Thoughts
Zero-downtime migration isn’t magic – it’s just testing first and switching last. Backup, transfer, preview via hosts file, flip DNS, and keep the old server alive for a safety window. Do it once this way and every future migration becomes routine.
How long does website migration to a new VPS take?
The actual transfer takes 1–2 hours for most sites. DNS propagation adds a few hours more, though lowering TTL to 300 seconds beforehand speeds this up dramatically.
Will my website go down during migration?
Not if you follow the zero-downtime method: set up and test the new server completely before changing DNS. Visitors continue hitting the old server until the switch, so there’s no gap.
How do I test my site on the new server before switching DNS?
Edit your computer’s hosts file to point your domain to the new server IP. Only your computer sees the new site; the rest of the world still sees the old one.






