admin管理员组文章数量:1421263
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
andwp-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. )
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
andwp-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. )
Share Improve this question asked Jun 26, 2016 at 10:16 Miloš ĐakonovićMiloš Đakonović 2851 gold badge4 silver badges13 bronze badges3 Answers
Reset to default 0This 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.
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 to example)
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.
本文标签: databaseExport only pages and posts with mysql dump
版权声明:本文标题:database - Export only pages and posts with mysql dump 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745331661a2653841.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论