Restoring a WordPress Site from File and Database Backups

I recently had to move a complete WordPress installation from one host to another. To do this, I compressed all the WordPress core files into a zipped folder and exported the MySQL database.

Technically, you only need to have the wp-contents folder with you, but I usually bring all files/folders as there may be specific changes made to .htaccess and wp-config.php that is needed for the website.

Backup Files

1. Enter cPanel and go to File Manager.
2. Then go to the directory with the WordPress installation.
3. Select everything and compress into a zip/gzip folder.
4. Download the zip folder to your computer or storage media.

Backup Database

1. Enter cPanel and go to PHPMyAdmin.
2. Select the database associated with the website.
3. Click on Export at the top menu bar.
4. I usually leave default selection and export the .sql file.

Upload Files

1. On the new server, upload the zipped folder with all the files to the proper directory.
2. Unzip the contents to the proper directory.

Import Database

1. I used the MySQL database wizard which quickly creates a DB and associated User by filling out a few form fields.
2a. I then open my .sql file and find the following line near the top.

USE 'wp123_dbname';

2b. I change the name of the DB to the new name made from the previous step.
3. I then access PHPMyAdmin and import this updated .sql file into the newly created DB.

Checking Other Files

1. I then had to update the following values in the wp-config.php file. DB_NAME, DB_USER, DB_PASSWORD. You may or may not need to update DB_HOST depending on your hosting server.
2. I also had to check .htaccess to ensure it contained the usual WP module block.

Waiting for DNS to Propagate

1. If you’re simply restoring a site on the same server, then you may need to clear local cache and cookies to see the results.
2. If you’re transferring hosts, then you may need to wait 24 hours for DNS changes to propagate around the world. If you upload everything too soon, you may see the old site still in the global cache.

Related Articles