Moving a site is safe when the old host keeps running until the new one works. You copy everything, test it, and only then change DNS. If something is wrong, you point the domain back.
You need a VPS with a web server, PHP and a database already installed. If you do not have that yet, follow set up WordPress on your VPS or set up a LEMP stack first.
1. Lower the DNS time-to-live a day before
In your domain's DNS settings, change the TTL of the A record to 300 seconds (5 minutes). This makes the final switch fast. Do it at least a day before you move.
2. Back up the old site
On the old host, export the database (your host's phpMyAdmin or mysqldump) and download the whole site folder (usually public_html). Keep these two copies safe until the move is finished and checked.
3. Copy the files to the VPS
From your computer, or directly between servers, copy the files with rsync (replace the names):
rsync -avz --progress user@oldhost:/path/to/public_html/ deploy@YOUR_VPS_IP:/var/www/example.com/
4. Create the database and import
sudo mysql -e "CREATE DATABASE wpdb CHARACTER SET utf8mb4;"
sudo mysql -e "CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'a-strong-password';"
sudo mysql -e "GRANT ALL ON wpdb.* TO 'wpuser'@'localhost'; FLUSH PRIVILEGES;"
mysql -u wpuser -p wpdb < backup.sql
Then edit wp-config.php so DB_NAME, DB_USER, DB_PASSWORD and DB_HOST match the new database.
5. Test before you switch DNS
On your own computer, edit the hosts file so your domain points to the VPS only for you:
- Windows:
C:\Windows\System32\drivers\etc\hosts - Mac and Linux:
/etc/hosts
Add the line YOUR_VPS_IP example.com www.example.com, then open the site in a browser. Check the home page, a post, the login, a contact form and, for a shop, a test order. Remove the line when you finish.
6. Switch DNS
Change the A record to your VPS IP. Within minutes most visitors reach the new server. Keep the old host for a few days.
7. After the move
- Install a free certificate: Free SSL certificate with Nginx and Certbot.
- Raise the DNS TTL back to a normal value, such as 3600.
- Check that email still works. If your email is hosted on the old host, do not cancel that host, and leave the MX records alone.
- Set up your own backups: back up your VPS with restic.
Need a hand?
Moving a busy shop or a site with email can be tricky. Our team offers managed migration.
Run it on your own VPS
VPS for WordPress in India: When a VPS is worth it, and which size to start with. Prices are in rupees, you can pay by UPI, and you get a GST invoice.