Knowledge Base
I can't restore my website because of my database connection
Overview
By the end of this article, you will be able to restore your website and its database as two separate operations when a database connection error blocks a combined restore. The article explains when this workaround applies, then covers the Selective Restore of your website files, the separate database restore from the dashboard, how to confirm both restores completed, and what to do when CodeGuard cannot reach the database at all.
When to use this workaround
Use this workaround when CodeGuard displays a database connection error while you are trying to restore your website, and CodeGuard has been able to connect to your database to take backups. If backups of the database have been running successfully, the data needed for a restore exists, and the website and the database can each be restored on their own. If CodeGuard has not been able to connect to your database for backups, this workaround does not apply — see the last section of this article.
Figure 1: Database Connection Error During Restore – CodeGuard was unable to establish a connection to the WordPress database. Update the database connection information before continuing with the restore process.
Before you begin
You need the following before restoring your website and database separately:
- Your CodeGuard sign-in credentials
- The date you want to restore your website and database to
- Confirmation that CodeGuard backups of the database have been completing successfully
Step 1 — Restore your website files with Selective Restore
Selective Restore lets you restore your website files on their own, without the database, which avoids the database connection error that blocks a combined restore.
- Sign in to the CodeGuard dashboard and select the website you want to restore.
- Choose the Selective Restore option for the restore.
- When you are prompted to select the files to restore, select the checkbox next to your home directory. Selecting the home directory selects all of the content beneath it for restore.
- Start the restore.
Step 2 — Restore your database separately
The database is restored from its own entry in the CodeGuard dashboard. This step is needed because Selective Restore covers website files only.
- In the CodeGuard dashboard, select your database.
- Click the Restore tab on the left side.
- If the date you want is not listed, click View All Backups.
- Locate the date you want to restore to, click Restore Options, and click Restore.
How to confirm both restores completed
CodeGuard notifies you when each restore has finished, so you receive one notification for the website files and one for the database. Wait for both notifications before checking the site. Then open your website and confirm that the content matches the date you restored to and that the site loads without a database error.
What to do if CodeGuard cannot connect to your database at all
If CodeGuard has not been able to connect to your database to take backups, no database backup exists to restore, and restoring the files alone will not return the site to a working state. Contact CodeGuard support with the error you are seeing and the name of the affected website, so that support can check the database connection settings held for your site.
Frequently asked questions
Why does my restore fail with a database connection error?
The error appears when CodeGuard cannot connect to your database at the time of the restore. If database backups have been running successfully, restore the website files and the database separately, using Selective Restore for the files.
What is Selective Restore?
Selective Restore is a CodeGuard restore option that lets you choose which files to restore instead of restoring everything at once. Selecting the home directory checkbox selects all content beneath it.
Do I have to restore the files and the database in a particular order?
Restore the website files first, then the database. CodeGuard notifies you when each restore is complete.
What if my database has never been backed up successfully?
Contact CodeGuard support. Without a successful database backup there is nothing to restore, and support can check the database connection settings held for your site.
Similar questions
- Why can't I restore my website because of a database connection error?
- How do I restore my WordPress database separately?
- What is Selective Restore in CodeGuard?
- My restore fails with a database error, what should I do?
- How do I restore my website files without the database?
Need assistance?
Contact our team for help with your purchase or issuing your certificate.