If you have both your website's files and database backups, follow this guide: restore your WordPress website.
Alternatively, if your WordPress website backup files are missing or corrupted, but you still have the database - you can still try to recover your website by following the steps below:
Step 1 - Import the Database
Locate your database file on your device - it should have a .sql file format. If your database backup is in an archive format, such as .sql.gz, make sure to unpack it first.
Next, follow these steps:
Step 2 - Restore the WordPress Installation
Create a fresh WordPress installation on your hosting:
Once the WordPress files are uploaded, access your WordPress Admin area - open this URL on your browser: domain.tld/wp-admin, replacing domain.tld with your domain name. Choose the language for your website, and click on Let's go!
You will be required to provide the database details. Insert the data from the database you created in the previous step:
Once the database connection is correctly established, you will get a message indicating that WordPress is already installed:
Click on Log in and enter the old credentials you used for your original website.
If you don't get the "Already Installed" notification, start over from the first step, making sure to double-check the database credentials and table prefix.
Step 3 - Reinstall the Theme and Plugins
With this restoration, your posts and pages, settings, custom CSS files, and users will be recovered. Next, you will need to reinstall the theme and plugins for your website to display properly.
For the theme, install your previous theme.
Then, open the Plugins menu and install the missing plugins. Since the database has records of all of the plugins you have previously installed, you will get a warning about each plugin that is missing:
This will help you identify all the plugins that you will need to install.
Step 4 - Fix Links
To ensure the internal links on your website work correctly, recreate the permalinks.
Step 5 - Fix Images
Since databases don't store images, you will need to re-upload each image. To help you with this task, you can use the following tools:
Broken Link Checker plugin
Install and activate the Broken Link Checker plugin. Next, open the plugin's settings - there will be a list of broken links. This will help you determine which images are missing and their previous location. All you need to do is re-upload these images:
If some or all of your images are missing, you can try to retrieve them from the Internet Archive using the WayBackMachine section. Enter your website address on the search bar:
If there are any snapshots available for your website, they will be shown as blue circles around certain dates on the calendar. Click on your preferred date to access that version of your website:
Once there, find the specific images, download them from the archived version, and upload them back to your website.
That's it! Your website has now been restored in the most comprehensive way possible using only the database.