How to export only pages and posts using mysql database to database approach? More precisely:

  • what tables should one select for dump (I suppose wp-posts and wp-post-meta )
  • is it safe to export only some of the tables (those that contains pages/posts data) and not all of them

( My goal is to sync development with production site, and because prod site has many features added post festum my choice is to export only pages and posts. Wordpress built-in export tool combined with available import plugins gave me nothing useful. )

3 Answers 3


This is generally not a good idea. See this WordPress database diagram. You need to consider:

  • posts that have categories or tags (terms), their relationships, term meta, and taxonomies
  • posts that have authors (users)
  • posts that have comments
  • things that are actually posts that you might not realise are posts (eg. almost everything in WordPress is a post - many plugins store their data as posts, some examples are Contact Form 7, Advanced Custom Fields field groups, and many many more)
  • anything else that might have been modified on your development install that isn't in sync with the live server (eg. are you sure no records have changed in the options table?)

In general, you should have a "live" copy of your database and any changes you make to your development database should be for testing purposes only, before you then repeat those changes on your live server. Doing anything else risks a long and protracted hunt through all of your data to ensure its integrity. Merging two databases is never fun.

Without knowing all the details of your situation, some options you potentially have might be:

  • WordPress import/export (which you said you tried, but it's unclear why this didn't work)
  • Manually re-inserting the posts you need to (which may or may not be prohibitive based on the number of them)
  • Adding the posts to a fresh table, then writing a script to loop through the records and run wp_insert_post() on each one
  • Grab a mysqldump of each database and do a diff to determine how much has really changed in the live site, and decide whether you can just override the database and manually set any options

There may be other solutions as well, and the best will depend on the details of your situation. With the information we have so far, I'd probably be leaning towards the scripting option above.

EDIT: Since this answer was originally written, Mergebot has been released. I haven't used it so can't vouch for it, but it looks promising, and the author has a track record of producing good plugins.


Content includes the author user and comments (and probably more). Dumping just part of the DB as a way to export/import doesn't sound like a very robust idea.

DBs are relatively small, and there is almost no reason not to export/import the full DB instead of trying to hack things.

  • Thanks for answer. But, trouble is, I don't dare to overwrite, lets say, production data of security or other plugins, other users passwords and so. That is the reason why I'm after solution which would affect only page and posts data. Jun 26, 2016 at 15:44
  • @Miloshio well, as the answer implies data needed to generate front end pages is unlikely to be limited to only those tables. copying only those table will work for only bery trivial sites Jun 26, 2016 at 17:06

You can use WordPress Import/Export tool to export pages and posts from your dev site to the production site. Keep in mind that you need to manually update all url in the production site after the import (e.g change dev.example.com to example.com)

Copy the entire database is risky if your production site has customer login and order records. I am looking for suggestions on how to use mysqldump to sync dev and production site without tampering production site's customer order records.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.