Whenever you start the WP STAGING Pro push process, several different steps and preparations are done in the background to make sure that migrating the data from the staging site does not break your live site.
There are two things you need to differentiate when you start migrating the staging site:
- Migration of file-based data
- Migration of database tables
So wait, you are talking about file and database tables.
What is the difference?
WordPress stores most of its settings in a unique location called the database. This data is organized in so-called ‘tables.’ The same goes for most of the plugins. They store the settings in this database.
The plugins themselves are based on text files (like a text document) and are separated from the database and its tables.
A file can be transferred from one location to another by copying it like you copy files on your local computer.
The content and data of the database can be accessed and requested by plugin files but the database itself can not be copied to another location like you would do it with a file.
To understand it better, I am going to explain it with an analogy.
You live in an apartment or house.
In that apartment you have furniture which you can place wherever you want:
The apartment is the database; the types of furniture are the database data organized in so-called tables. You can arrange the furniture/table data, but you can not move the apartment/database to another location. At least not without extremely technical challenges and much bigger machines;)
Let’s have a real case example – Push a Plugin.
You were installing a new plugin or did an update for an existing one on the staging site. If you just updated the plugin and did not change any of its settings, it’s sufficient to copy over the plugin files to the live site by following the steps below:
- Go to WP Staging > Sites / Start
- Click on the Push-button.
- Select the plugin folder that contains the new /updated plugin or select all folders.
- Unselect all database tables
Start the push process…
When you visit the live site, you will see that the plugin has been updated, thereby copying the plugin files to the live site.
Why is it often helpful to copy plugin and theme files only or exclude certain database tables from migration?
Think about woocommerce shop orders or user comments on your website.
There are likely new comments or orders made after creating a staging site. WP Staging allows you to exclude certain tables before executing the migration process to prevent overwriting of these data transactions.
Doing it ensures that no database data is copied from the staging site to the live site. That ensures that no settings, orders, comments, or any other custom data are overwritten on the live site.
What about If I need to copy theme or plugin settings?
If you like to migrate all of the staging site data, including plugin or theme settings, then you need to copy the data from the database to the live site – remember our furniture?
Technically, this isn’t very easy. It’s not sufficient to get the data from the database and copy it to the live site’s database tables. It’s also necessary to do a complex search & replace string operations on the data before copying it to the live site. Complex because WordPress stores a lot of its data as serialized data.
A Search & Replace Example:
All links that contain the path to the staging site must be converted before they can be used on the live site:
There are dozens of similar and more complicated operations necessary before the staging site data can be used for the live site. Explaining every step is out of scope for this article and not necessary to understand the process.
The important thing for you to know is that WP Staging handles all those search & replace operations automatically for you!
So, back to our pushing the database example.
In that example, I am demonstrating what is happening to the single database table
wpstg_options when we migrate it to the database table
wp_options which is used by the live WordPress site.
Whenever you decided to push all or only particular database tables from the staging site to live site – move furniture from one room into another – the following is happening in subsequent order:
- All staging tables are copied to new tables, and their names are prefixed with
E.g., the table
wpstg(0)_optionsis renamed to
- Several search & replace operations are running on that newly created database table
- The live table
wp_optionsis copied as
wpstgbak_optionsfor backup purposes in case something goes wrong. So we can recover the live site anytime with that table.
That’s it. After reloading your live site, you will see that all plugin and theme settings are migrated to the live site.
I hope this article gives you a good overview of how WP Staging is working behind the scenes.
If you like this article, please share it with your friends and colleagues.