How to Back Up Your Website Before Changing Hosts
In this article
Backing up before changing hosts means downloading a complete copy of your website files and database, then verifying that the copy is usable. This protects you if the new host's migration fails, if DNS changes go wrong, or if the old host deletes your account before you have confirmed everything works. The shortest working set of steps: download all files from your old host, export the database, save both in two places, and test the backup before you cancel anything.
What You'll Need
- Login credentials for your old hosting control panel (cPanel, Plesk, or a custom dashboard) and for any database management tool such as phpMyAdmin.
- FTP or SFTP client (FileZilla is common) or the host's built-in file manager.
- A local computer with enough free disk space, plus an external drive or cloud storage folder for a second copy.
- The site's configuration file (for example
wp-config.phpon WordPress) or equivalent, which contains database connection details you will need later. - Access to your domain registrar account, in case you need to check DNS records later.
Step-by-Step
- Put the site in maintenance mode or pause changes. On WordPress, use a maintenance plugin or temporarily set the site to private. On other platforms, stop editing content and tell collaborators not to publish. This prevents new posts, orders, or comments from arriving after you take the backup.
- Export the database first. Open phpMyAdmin from your hosting control panel, select the database that belongs to your site, and choose Export. Use the Quick export method with SQL format, then save the
.sqlfile to your computer. If the database is large, use the Custom method and enable compression. Note the database name, username, and host from your configuration file; you will need them when setting up the new host. - Download all website files. Connect with FTP/SFTP or open the File Manager. Navigate to the public web root (often
public_html,www, orhttpdocs). Download the entire folder, including hidden files such as.htaccess. Do not skip uploads, themes, plugins, or custom folders. If your host offers a one-click full backup or account backup, use it as an extra copy, but still download files manually so you have a copy you control. - Save email and DNS records if you use them. Export any mailboxes you need through the host's email tools, and take a screenshot or text copy of your DNS zone (A, CNAME, MX, TXT records) from the registrar or hosting panel. You will compare these after the move.
- Store the backup in two separate places. Keep one copy on your computer and one on an external drive or cloud folder. Name the files with the date, for example
site-backup-2025-06-01.sqlandsite-files-2025-06-01.zip, so you can tell versions apart. - Verify the backup before you rely on it. Unzip the files archive and confirm that key folders and the configuration file are present. Open the
.sqlfile in a text editor and check that it containsCREATE TABLEstatements and data rows, not just comments. A file that is a few kilobytes is almost certainly incomplete. - Test the restore on a local or staging environment if possible. Import the database into a local MySQL install and point a local copy of the site at it. If that is not practical, at least confirm the archive opens without errors and the database file imports into an empty database on the new host before you change DNS.
- Only then change nameservers or DNS and cancel the old account. Keep the old hosting active until the new site loads correctly and you have received a test email. Most hosts keep cancelled accounts accessible for a short grace period, but do not depend on it.
Common Mistakes
- Downloading only the
public_htmlfolder and forgetting databases stored outside it, or forgetting email accounts. - Skipping hidden files such as
.htaccess, which control redirects and permissions. - Exporting the database after making content changes, so the files and database no longer match.
- Keeping a single copy on the same server you are about to cancel.
- Assuming the host's automatic backup is enough without downloading it. Those backups are often deleted when the account closes.
- Changing DNS before verifying the backup, leaving no working copy if the new host fails.
Tips
- Take the backup during low-traffic hours to reduce the chance of missing an order or comment.
- Write down the database name, username, password, and host before you leave the old panel; the new host will ask for them.
- Use SFTP rather than plain FTP where available, since it encrypts the transfer.
- Keep the old host active for at least a few days after the new site is live so you can compare behaviour.
- Label backups clearly and delete old ones only after the new site has run without problems.
Troubleshooting
The database export fails or times out. Large databases often exceed browser limits. Use the Custom export option with compression, or export table by table. If the control panel offers a command-line tool, ask the host's support whether you can run a database dump from the terminal.
The file download stops partway. Reconnect and resume, or download folder by folder. Check that the total size roughly matches what the control panel reports for disk usage.
The SQL file looks empty or tiny. You may have exported only the structure. Re-export and confirm the option to include data is selected. If the database truly is empty, check that you selected the correct database name.
The backup will not import on the new host. The new server may run a different database version. Ask the new host's support to import the file for you, or use a migration plugin that handles version differences. Do not delete the old copy until the import succeeds.
You already cancelled the old account. Contact the old host immediately and ask whether the account can be restored temporarily. If not, check whether you have an earlier backup or whether the host retains a copy. This is why the verification step matters.
Frequently Asked Questions
Do I need to back up email as well as website files?
Yes, if you use mailboxes on the old host. Website files and databases do not include email. Export mailboxes through the host's email tools or set up forwarding before you cancel.
Can I just use the host's automatic backup?
Use it as an extra copy, but download your own files and database. Automatic backups are usually tied to the account and may be removed when it closes.
How do I know the database backup is complete?
Open the SQL file and confirm it contains table creation statements and data rows. A file of a few kilobytes is almost certainly incomplete. Importing it into an empty database is the strongest check.
Should I change DNS before or after restoring the backup?
Restore the backup on the new host first, confirm the site works using a temporary hosts file entry or the new host's preview URL, then change DNS. That way visitors never see a broken site.
What files are most commonly missed?
Hidden files such as .htaccess, upload folders, custom theme or plugin directories, and configuration files that sit outside the public web root.
How long should I keep the old hosting account?
Keep it active until the new site loads correctly, email works, and you have tested a form or order. A few days is typical; do not cancel on the same day you change DNS.