How to Backup and Restore WordPress

This article explains the backup function of WP STAGING | PRO.

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


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

 

Create a Backup of a WordPress Website

Let’s start.

First, open the WP STAGING | PRO plugin.

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

If you are not sure how to install the WP STAGING plugin, read the article “How to install WP STAGING Pro“.

Click on the “Backup & Restore” button, and WP STAGING | PRO lists all existing backups.

Backup & Restore Button
Backup & Restore Button

You’ll see two options: “CREATE NEW BACKUP” and “UPLOAD BACKUP.”

Click on “CREATE NEW BACKUP.”

Create New Backup Button
Create New Backup Button

You can optionally assign a name to better identify the backup.

Set up a name for the backup
Set up a name for the backup

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

Then select the components of your website that WP STAGING | PRO  should include in the backup. Unless you want to carry out a particular component, leave all the boxes selected.

Click on “Start Backup.”

Start the Backup Process
Start the Backup Process

The time it takes to create a backup differs and depends on the size of your website, but the 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.

The Backup is Completed
The Backup is Completed

When the backup is ready, you will find the backup 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 Same or Another Server (Migration)

To restore the backup, you can either select the backup from the list of existing ones 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.

Upload Backup Button
Upload Backup Button

Select the downloaded backup from the file explorer and upload it.

Select the WP STAGING Backup File
Select the WP STAGING Backup File

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

Click on "Restore"
Click on “Restore”

If the restore is successful, you will see the “Finished” modal.

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)

If you created a backup from a multisite network and you want to restore the backup on another existing multisite, for example, to copy the multisite to another server, there are a few things to consider, depending on the type of 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:

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

    foreach ($adjustedSites as $site) {
        $adjustedDomain = explode('.', $site['domain'])[0] . '.' . $baseDomain;
        $site['new_url'] = str_replace($site['new_domain'], $adjustedDomain, $site['new_url']]);
        $site['new_domain'] = $adjustedDomain;
    }

    return $adjustedSites;
});

 

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:

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

    foreach ($adjustedSites as $site) {
        $adjustedDomain = explode('.', $site['domain'])[0] . '.' . $baseDomain;
        $site['new_url'] = str_replace($site['new_domain'], $adjustedDomain, $site['new_url']]);
        $site['new_domain'] = $adjustedDomain;
    }

    return $adjustedSites;
});

 

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

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.

Updated on January 16, 2023