How to Backup and Restore WordPress

Learn how to save your entire website with WP Staging and how to back up and restore your WordPress website much faster than with any other backup plugin.

With WP Staging, You can create a backup of your entire WordPress website with one click and save it locally. You can also set up scheduled backup plans. So, If your website breaks due to an updated plugin or an attack, you can restore it and bring it back to its previous working state.

If you’d rather watch a video than read it, look here. It explains all the steps of how to back up and restore WordPress:

Backup WordPress

Restore a WordPress backup

Create a Backup of a WordPress Website

Let’s start.

If you have not done so, install the WP STAGING | PRO plugin first and read the article “How to install WP STAGING | PRO“.

Go to WP Staging > Backup & Migration:

WP STAGING Pro Plugin in the Sidebar Menu
WP STAGING Pro Plugin in the Sidebar Menu

Click on “CREATE BACKUP.”

Create WordPress backup

In the opening modal, assign a name to identify the backup better and select if you want to back up the whole website or only plugins, themes, media files, or the database.

If you run a WordPress multisite website, you can specify if you want to back up all or only the current network website.

WP Staging Backup Settings. Specifiy if you want to backup the whole website or only plugins, themes, media files or the database.
Set up a name for the backup.

So, for instance, if you plan to update WooCommerce or any other plugin, you could name your backup “Backup before installing WooCommerce.”

Then select the components of your website that WP STAGING | PRO  should include in the backup. Leave all the boxes selected unless you want to carry out a particular element.

Click on “Start Backup.”

The time it takes to create a backup differs and depends on the size of your website, but WP STAGING’s backup is pretty fast and often much faster than other backup tools. So, especially for huge sites, you will notice a considerable performance advantage compared to other backup plugins.

Backup complete modal. This appears when the backup has been successfully created.
The Backup is Completed

When the backup is ready, you will find it under “Your Backups.” The icons indicate which components the backup includes.

The Backup Contains these Components
The Backup Contains these Components

Download the Backup File

To download the backup, click Actions > Download. That will download a file with the extension “.wpstg.”

Download the Backup
Download the Backup

Downloading the backup file to a local computer is recommended because you want to ensure that you always have access to the backup file. For instance, If an attacker hacks your website, he could delete the backup file from there, and you would not be able to restore the site anymore.

The Backup File with the Extension ".wpstg"
The Backup File with the Extension “.wpstg”

Restore the Backup on the Same or Another Server (Migration)

To restore the backup, you can select the backup from the existing list or upload the backup file from your local computer.

You can even upload the backup file to any other existing WordPress website and use that backup file to clone your website to another hosting provider and server.

Go back to WP STAGING and click the “Upload Backup” button.

click on the "Upload Backup" button to upload the WordPress backkup file.
Upload Backup Button

Now, you can either upload the backup from your local computer where you have stored it before or even faster, you can copy the backup URL from the site you have created the backup.

This will copy the backup file directly from the original server and it will usually much more faster than uploading it from your local computer.

upload backup
Select the WP STAGING Backup File

Optional – Skip this step if you upload the backup from your local computer:

If you want to upload the backup by using its backup URL, go to the your source website, WP Staging > Backup & Migration > Actions > Copy Backup URL:

Copy Backup URL

Once the backup is uploaded, click on Actions and Restore.

Click on "Restore"
Click on “Restore.”

You will see the “Finished” modal if the backup restore is successful.

WP STAGING Pro Restored the Backup Successfully
WP STAGING | PRO Restored the Backup Successfully

Open your website and test whether the website works as intended and is entirely functional.

Restore a Multisite Backup on Another Multisite (Migration)

Suppose you created a backup from a multisite network and want to restore the backup on another existing multisite, for example, to copy the multisite to another server. In that case, there are a few things to consider, depending on the multisite you operate:

WP STAGING can handle out of the box the following different multisite setups:

Restoring subdirectory backup on subdirectory multisite:

example.com will turn into destination.com
example.com/site1 will turn into destination.com/site1
example.com/site2 will turn into destination.com/site2

Restoring subdirectory backup on subdomain multisite

example.com will turn into destination.com
example.com/site1 will turn into site1.destination.com
example.com/site2 will turn into site2.destination.com

Restoring subdomain backup on subdirectory multisite

example.com will turn into destination.com
site1.example.com will turn into destination.com/site1
site2.example.com will turn into destination.com/site2

Restoring subdomain backup on subdomain multisite

example.com will turn into destination.com
site1.example.com will turn into site1.destination.com
site2.example.com will turn into site2.destination.com

Restoring domain-based backup on subdirectory multisite

example.com will turn into destination.com
site1.com will turn into destination.com/site1.com
site2.com will turn into destination.com/site2.com

To remove the Top-Level Domain ending, E.g. *.com (TLD), you can use this filter:

PHP
add_filter('wpstg.backup.restore.multisites.subsites', function($sites, $baseDomain, $basePath, $siteURL, $homeURL, $isSubdomainInstall) {

    $adjustedSites = [];

    foreach ($sites as $key => $site) {
        $site['adjustedPath']    = str_replace('.com', '', $site['adjustedPath']);
        $site['adjustedSiteUrl'] = $site['adjustedDomain'] . $site['adjustedPath'];
        $site['adjustedHomeUrl'] = $site['adjustedDomain'] . $site['adjustedPath'];

        $adjustedSites[] = $site;
    }

    return $adjustedSites;
}, 10, 6);

Copy this filter in a mu-plugin and then start the backup restore process.

As a result:

example.com will turn into destination.com,
site1.com will turn into destination.com/site1
site2.com will turn into destination.com/site2 

Restoring domain-based backup on subdomain multisite

example.com will turn into destination.com
site1.com will turn into site1.com.destination.com
site2.com will turn into site2.com.destination.com

To remove the Top-Level Domain ending, E.g., *.com (TLD), you can use the same filter as above:

PHP
add_filter('wpstg.backup.restore.multisites.subsites', function($sites, $baseDomain, $basePath, $siteURL, $homeURL, $isSubdomainInstall) {

    $adjustedSites = [];

    foreach ($sites as $key => $site) {
        $site['adjustedDomain']  = str_replace('.com.', '.', $site['adjustedDomain']);
        $site['adjustedSiteUrl'] = $site['adjustedDomain'] . $site['adjustedPath'];
        $site['adjustedHomeUrl'] = $site['adjustedDomain'] . $site['adjustedPath'];

        $adjustedSites[] = $site;
    }

    return $adjustedSites;
}, 10, 6);

example.com will turn into destination.com
site1.com will turn into site1.destination.com
site2.com will turn into site2.destination.com

Replace destination hostname while restoring a multisite backup

Use the filter below to change the hostname of the destination multisite while restoring a multisite backup.

Example
www.example.com will turn into sandbox.example.com

PHP
add_filter('wpstg.backup.restore.multisites.subsites', function($sites, $baseDomain, $basePath, $siteURL, $homeURL, $isSubdomainInstall) {

    $adjustedSites = [];

    foreach ($sites as $key => $site) {
        $site['adjustedDomain']  = str_replace('www.', 'sandbox.', $site['domain']);
        $site['adjustedSiteUrl'] = $site['adjustedDomain'] . $site['adjustedPath'];
        $site['adjustedHomeUrl'] = $site['adjustedDomain'] . $site['adjustedPath'];

        $adjustedSites[] = $site;
    }

    return $adjustedSites;
}, 10, 6);

That’s it. With WP STAGING | PRO, you have created a backup of your entire WordPress website and learned how you can restore your WordPress website from a backup or restore the backup on another system.

Related Articles

Updated on August 20, 2024