I recently wrote an tutorial about how to backup WordPress. If you’re not already creating backups, read the article and get started now. This tutorial explains how to restore WordPress from a backup .zip file that contains all the site files plus an SQL database file.
If you’re still reading, you probably need to restore WordPress from a backup file. In order to restore your WordPress site, you will need a copy of all the site files and an SQL export file of the database.
Considerations for Restoring Your WordPress Website
- Before you perform this procedure, contact your web host to see if they can restore your site for you. Web hosts usually keep the last 24 or 48 hours of site backups.
- If your site was hacked, you need to find a backup file that was created before the site was hacked. In my how to backup WordPress article, I explain how to save a complete backup each week for 8 weeks. As a result, you will have two months of backups to choose from.
- If your site was not hacked, then you can use the most recent backup.
- This tutorial uses cPanel hosting control panel as an example. You can, however, restore WordPress using almost any hosting control panel that provides a file manager and phpMyAdmin.
- This tutorial assumes you are restoring WordPress from a backup using the same host and database that your site used before the restore was necessary. See Moving your WordPress Website if you are moving your site to another host or server.
To Restore WordPress from a Backup
1. Move the existing site to a directory above the web root
The web root is the folder where all your website files are stored on the web host server. Usually, there is an account folder one level up from public_html; eg, /mysite/public_html
- Log into your webhost cPanel and open FileManager.
- In your main account folder, create a new folder called old-site
- In the left column of the File Manager screen, click public_html to select it.
- Click Select All to select all files in /public_html (website root).
- Click Move File
The Move File screen is displayed.
- In the Enter the path to the file… field, enter /old-site and then click Move Files.
All the files in /public_html are moved to /old-site.
2. Copy the Backup file to /public_html and Extract
- Locate the backup file in the /old-site folder, or find the backup file in the location you have stored it.
If you’re using the BackUpWordPress plugin, the backups are located in
/old-site/wp-content/backupwordpress-xxxxxxxxxx-backups
Make sure you get the complete backup file; for example,
site-name-com-xxxxxxxxxx-complete-2016-06-14-13-20-41.zip - Select the backup file and click Copy
The Copy screen is displayed.
- In the Copy file to: field, enter /public_html and then click Copy File(s)
The backup file is copied to /public_html - Select the backup file in /public_html and click Extract.
The Extractor will run and present a list of files extracted. Close the extractor screen. You should see all the WordPress files in /public_html
3. Import the WordPress Database File
- From the cPanel File Manager screen, select the slq file and click Download; eg,
sitename-com-xxxxxxxxxx-database-2016-06-01-18-00-05.sql
Depending on your browser, the sql file will automatically download to the browser’s default download folder. - From the Main cPanel screen, click phpMyAdmin.
The phpMyAdmin screen is opened.
- Click on the database name to make it active.
- Click Check All to select all the tables in the database.
- From the With selected list.
phpMyAdmin displays a new screen: Do you really want to execute the following query? - Click Yes to drop (delete) all the database tables.
- Click the Import tab.
The phpMyAdmin import screen is displayed. - Click Choose File, and then select the sql database file from your site backup.
- Click Go to import the sql file.
phpMyAdmin displays the message: Import has been successfully finished - In phpMyAdmin, select the database to verify that the tables were successfully imported.
Test Your Website
After completing the Restore WordPress from a Backup procedures, go to your website and verify that it is running.
4. Clean After Restore WordPress from a Backup
- Delete the .sql file from /public_html
- Delete the .zip backup file from /public_html
Leave a Reply