How to Migrate a Website to a New Host

This article will show you how to migrate a website to a new host with as little downtime as possible.
1. Take a Full Backup First
Back up the files and the database from the old host before touching anything. Keep a copy on your own computer, not only on a server.
2. Set Up the Site on the New Host
Create the hosting account, add the domain, and upload the files. Do this before changing anything that visitors rely on.
3. Import the Database
Create a database and user on the new host, import the dump, then update the application's configuration file with the new details.
4. Test Before Switching
Preview the site on the new server using a temporary address or by editing the hosts file on your computer. Check the pages that do real work, not just the home page.
5. Lower Your DNS TTL
A day before the switch, reduce the TTL on your DNS records to 300 seconds. Visitors then pick up the change in minutes rather than hours.
6. Point the Domain at the New Host
Update the name servers or the A record. Keep the old hosting running for at least a week, because visitors reach whichever server their resolver still has cached.
7. Move Email Separately
Email is the part that catches people out. Create the mailboxes on the new host before the switch, and copy existing mail across with an IMAP transfer tool.
8. Check Everything, Then Cancel
Once traffic is arriving on the new server and mail is flowing, confirm forms, checkout and scheduled tasks all work before cancelling the old account.
Next: lowering the TTL first is covered in What Are DNS TTL Values and How to Set Them.