Migrate WordPress Staging Site to Production Site

How to Push WordPress Staging Site to Production Site

The tutorial below explains how to migrate your site by using WP Staging Free version. Read the instructions below very carefully and do not miss any step!

If you want to read the Migration instructions for WP Staging Pro instead please read this article.

The video below shows WP Staging Pro pushes your staging site to the production website.

WP Staging free version needs manual steps to do it. So let’s get started with using WP Staging free version to convert the staging site to the production one.

Goal: After reading this tutorial you are able to convert your existing staging site to the live website.

Limitations: Contrary to the use of WP Staging Pro this manual process makes your staging site unavailable and you need to create a new one after finishing the whole process.

How to Move Over Complete Staging Site to Production

Requirements for this tutorial:

  • One live site which is in production use e.g. https://host.com
  • One staging site which you previously created with WP Staging or WP Staging Pro. Staging site should be located in a subfolder like https://host.com/staging
  • Plugin WP Staging activated on live site
  • Plugin Better Search Replace activated on live site
    (Not needed for WP Staging Pro)
  • Plugin BackWPup (or any other backup software) used on live site

1. Step – Backup Live and Staging Site

At first, backup the entire live and staging site.

I recommend the BackWPup plugin which is a great and very reliable backup tool. Even the free version allows to backup files to FTP, Amazon S3 storage or to a folder on the server.

I do not explain the use of BackWPup here but it is very self-explanatory.

Note: At the file selection dialog of BackWPup make sure to select and include the WP Staging subfolder of the staging site. This is important to make a backup copy of your staging site as well. Also, include all database tables beginning with the prefix wpstg_

2. Step – Copy Files

Use an FTP program like Filezilla and copy over the folders wp-content/uploads, wp-content/plugins and wp-content/themes from your staging site subfolder to the production site.

3. Step – Migrate the database with WP Staging

You have two options to migrate the database data of the staging site so that it can be used for the live database:

  • Option 1 – Easy: Go the easy route and use some search & replace in the database staging site tables and tell WordPress to use the staging database tables for the live site. The database tables of the live site will not be overwritten, nor any of its data are going to be deleted. You can switch over to the previous database tables anytime in case something is not working as intended. Go to step 4.1
  • Option 2 – Advanced: Use a separate DB migration plugin migration plugin.
    Go to step 4.2

3.1. Convert Staging DB Tables to Live Database

This is the easiest way and recommended if you do not care that the live site will use the staging site database tables after the conversion process.

Note: After doing that your staging site will not be available any longer and you need to create a new one.

At first, you need to do a search and replace over the staging database tables.

Find all strings containing the path to the staging site and replace them with strings leading to the live site.

Fortunately, there is a nice plugin we can use to do this step without the need for manual interaction. If you haven’t already installed the plugin  Better Search Replace

Next, Go to Tools > Better Search Replace

We assume that your staging site is located in http://yoursite.com/staging

You can test this by opening the staging site and checking the complete URL in the browser window.

  • Enter the following string into the Search for input field
mysite.com/staging

Enter the string below into the Replace with field

mysite.com

Make sure to work accurately. Enter exact strings!

– Do not enter any trailing slash after the URL!
– Do not enter http:// or https:// to the search string

Any misspelling will lead to a broken staging or even live site.

Next, select all the tables which begin with the table prefix of the staging site. Usually, these ones begin with wpstg*_

You can find out the correct table prefix by looking into the list of staging sites:

If you are using an older version of WP Staging you need to check out the table prefix by looking into the wp-config.php of the staging site:

To do so just open the file below by logging in with FTP to your website:

path_to_wordpress/staging_name/wp-config.php
Do not select any other tables!
All other tables belong to the live site or to other staging sites which must not be altered in any way!

In the next step, you can select the dry-run option. This allows to run the search and replace process without changing any real data and is a good indicator if the provided settings are correct and if the search and replace plugin is working as expected.

Click on the Run Search/Replace button.

If the dry-run has been run successfully to the end, deselect the dry-run option and run the search and replace process again.

Remove database value wpstg_is_staging_site

The next step is to delete the value in the database which checks if a database table belongs to the staging site or to the live site. This is used by WP Staging to show the authentication screen.

Use a database administration tool of your choice e.g. phpmyadmin or adminer and search the database tables of the staging site for the value

wpstg_is_staging_site

Delete this value or set it to false.

If this is also successfully you just need to do one more step and you are done:

Alter wp-config.php

The last step is to tell the WordPress live site to use the database tables of the staging site.

For this, you need an FTP account to access your website and a FTP software. I recommend the use of filezilla. It’s entirely free and open source.

Login to your website with the FTP program and open the config file of your live site:

wp-config.php

Open the file in edit mode by opening the context menu with right mouse button and select edit

Use FTP again and open the config file wp-config.php of your live site.
The file is located in /path_to_wordpress/wp-config.php
Change the value of $table_prefix to the same value that is used by the staging site, e.g.

$table_prefix = 'wpstg1_';

The end result in your editor is looking like this:

This makes sure that your live site is using all the database tables of the staging site.

You are done. Just open the live site and you will see that it reflects all the data from the staging site.

If you like to enable permalinks you just need to login to the admin dashboard and enable permalinks fro settings > Permalinks

Now, the live site is using the staging site database and all the content from the staging site has been copied over to the live site.

Now, you can delete the old staging subfolder by using FTP:

path_to_wordpress/staging_name

As the staging site database tables are used by the live site you need to create a new staging site now.

3.2 – Use a Plugin to Migrate Database to Live Site

Another way to migrate the database data of the live staging site to the database that is used for the live site is to use a separate plugin. There is a plugin called WP Migrate DB. This plugin allows you to copy over all data. It also allows you to do some search and replace to make the necessary data modifications. I will not explain here the instruction of this tool but it’s very simple and there are already some very good tutorials about it on YouTube.