How to restore a WordPress backup: files, database, and wp-config.php
To restore a complete WordPress backup, you put back two parts: the site files (themes, plugins, and uploaded images) and the database (pages, posts, and settings). The files go back through the cPanel File Manager or via FTP, the database is imported through phpMyAdmin, and wp-config.php must point to the right database.
This article is for anyone who already has a copy of the site and needs to put it back, after an error, a break-in, or a faulty update. To create the copy, see how to back up WordPress.
Before restoring: protect what exists today
Restoring overwrites the current site. Before you start:
- Download a copy of the current state, even if it’s faulty: the files and an export of the database. That way you can go back.
- Check the date of the backup. Posts, orders, and comments created after that date will no longer exist on the restored site.
- Confirm that the backup has both parts: the files (usually a
.zip) and the database (a.sql, sometimes.sql.gz).
What does a complete WordPress backup contain?
| Part | What it stores | Where it is |
|---|---|---|
| Files | Theme, plugins, uploaded images, wp-config.php, .htaccess |
Site folder, usually public_html |
| Database | Posts, pages, users, settings, plugin data | MySQL or MariaDB, accessed through phpMyAdmin |
Is there a faster way to restore?
If your panel has a backup restore tool, it puts back the files and the database without you touching them. Look in cPanel for Backup, Backup Wizard, or a backup tool provided by your host. One example is described in backup in cPanel with JetBackup. If your panel doesn’t have one, or if the backup came from somewhere else, follow the manual steps below.
How do you restore the files through cPanel or FTP?
- In cPanel, open the File Manager and go to the site folder (on a primary domain, it’s usually
public_html). - If there are already WordPress files there, download a copy, and then rename
wp-admin,wp-includes, andwp-content. Keepwp-config.phpfor now. - Click Upload and send the backup’s
.zip. - Right-click the file and choose Extract. Check that the folders ended up directly in the site folder, not inside a subfolder.
- Via FTP, the process is the same: extract the archive on your computer and upload the contents with a client such as FileZilla.
To see .htaccess, turn on Show Hidden Files in the File Manager settings.
How do you import the database with phpMyAdmin?
This is the part that needs the most care, because importing over existing tables can mix old and new data.
- In cPanel, open phpMyAdmin and choose your site’s database in the left column. If you don’t know which one it is, it’s listed as
DB_NAMEinwp-config.php. - Export the current database through the Export tab, as a backup.
- To empty the database, open the Structure tab, select all tables, and under With selected, choose Drop. Only confirm if you made the copy in step 2.
- Open the Import tab, choose the backup’s
.sqlfile, and click Import (or Go). phpMyAdmin also accepts the compressed file. - When it finishes, the WordPress tables appear in the list.
How do you adjust wp-config.php after restoring?
wp-config.php tells WordPress which database to use. If the restored database has a different name, user, or password, the site shows a connection error. Open the file with Edit (download a copy first) and check:
define( 'DB_NAME', 'database_name' );
define( 'DB_USER', 'database_user' );
define( 'DB_PASSWORD', 'database_password' );
define( 'DB_HOST', 'localhost' );
$table_prefix = 'wp_';
- Name, user, and password must match the imported database. In MySQL Databases in cPanel, you can check the names and link the user to the database.
$table_prefixmust match the prefix of the imported tables. If the tables are namedabc_posts, the value isabc_.DB_HOSTis usuallylocalhoston cPanel hosting, but confirm whether the site used a different value before.
If you see a connection error, see error establishing a database connection in WordPress.
How do you restore with a backup plugin?
Plugins such as UpdraftPlus or Duplicator restore through the WordPress dashboard, and they work as long as the dashboard still opens:
Open the plugin’s backup list, choose the backup, click Restore, and select what to bring back (database, plugins, themes, uploads). If the dashboard doesn’t open, use the manual method above. The details vary from plugin to plugin, so follow the documentation of the one you use.
What to check after restoring
- Open the homepage, a few internal pages, and
/wp-admin. - Go to Settings > Permalinks and click Save Changes without changing anything. This rebuilds the address rules. See also internal pages showing a 404 error.
- Test forms, the checkout (if there’s a store), and email sending.
- If the domain changed during the process, follow how to change the domain or the address of a WordPress site.
- Make a new backup of the restored site.
If you’d rather not handle the files and database yourself, contact MigraCloud.
Frequently asked questions
Can I restore only the database, without the files?
Yes, if the problem is in the content or settings and the files are correct. But if the theme or plugins changed since the backup, the old database may not match them. Make a copy of the current database before doing this.
Does importing the database delete what already exists?
It depends. A backup .sql file usually recreates the tables, but it can fail or mix data if they already exist. The safest approach is to export the current database and empty the tables before importing.
How do you restore a WordPress backup on another domain?
The steps are the same, but the database stores the old address. After the import, update the site address by following the article about changing the domain. Avoid replacing text blindly inside the .sql file, because some WordPress data stores the length of its text.
phpMyAdmin won’t accept the file. What should I do?
The file is probably larger than the upload limit. Try compressing the .sql as .zip or .gz, split it into parts, or ask your host’s support to import it for you.
Do I need to reinstall WordPress before restoring?
No, if the backup contains the complete files. If it contains only the wp-content folder and the database, install a clean copy of WordPress, connect it to the restored database through wp-config.php, and then put the wp-content folder back.
Can I lose data when restoring a backup?
Yes: anything created after the backup date. Download a copy of the current state beforehand and, if you have a store, let your team know about any orders placed during that period.