Syncing Posts From Production Site to Staging Site

Question: How can I sync posts from my live site to my staging site (blog/dev)? There have been a lot of new posts while the staging site has been in development, and I don’t want to risk pushing my updates unless the posts are replicated across both environments

Answer: Exporting the posts is the first step of the process and can be done with tools directly on WordPress. Be sure to perform the export from the production site to copy the posts to the staging site.

Export posts from WordPress

1. Log in to the production site wp-admin.
2. Navigate to Tools > Export
3. Choose posts for export:

Warning: Choose posts only! Selecting all content would overwrite all posts, pages, and media. This may result in losing the changes made on the staging site.
4. Click on Download Export File

Import Posts to WordPress

Importing posts into the staging site requires you’ve first exported the posts from the production site. Make sure you’ve downloaded the .XML file from the previous step. Make sure to perform the import process on the staging site.

1. Log in to the wp-admin dashboard of the staging site
2. Navigate over Tools > Import. If you do not have the WordPress importer installed, you will see a prompt to install the plugin and must do so before continuing
3. Scroll down to WordPress and click Install Now
4. Now click on the Run Importer

5. Click on choose file and select the .XML file

6. Click on the Upload file and import button.
7. Assign posts to exist, WordPress user, and make sure to check the Download and import file attachments.

9. Finally, click on the Submit button.
10. All done, the new posts are imported, and already existing posts are not touched.

Alternative Option: Update Posts and Pages with WP STAGING

To do so just click on the update button and select the tables wpstg_posts and wpstg_postmeta only.

Exclude and unselect all other tables and directories except the folders that contain your new images if there are any!

Attention: Updating means that ALL posts and pages on the staging site will be overwritten with data from the live site!

These tables will be copied over to the staging site. If you have posts on the staging site that you do not have on the production site you should create them first on the live site to prevent these tables from being overwritten.

My advice for the future is to create content either on the staging site or to update the staging site more often. Then you make sure that both sites are not running much out of sync.

There is an article about the WordPress database structure which helps you to understand which database table contains data and makes your decision easier which table needs to be excluded when you copy over data from one site to another:

Updated on May 16, 2021