0

I have a live site and a backup/dev version of the site.

For some reason (probably because I did an export from Moveable Type then moved everything from localhost to a live environment I had little control over), the live site has several posts which have been cut short at special characters. The backup version has the full versions of these posts, but the ID values are different.

I'd like to merge my backup wp_posts table with the live wp_X_posts (it's on multisite - again, no control over this), updating post_content on live with post_content on backup where post_name matches.

My MySQL is failing me right now. Can anyone help?

0

Found it with help from a Twitter follower! Might be handy for others.

Get your backup table and import in to your live DB with a new name, e.g. wp_posts_updated. Then run this query:

UPDATE wp_X_posts LEFT JOIN wp_posts_updated ON wp_posts_updated.post_name = wp_X_posts.post_name SET wp_X_posts.post_content = wp_posts_updated.post_content WHERE wp_posts_updated.post_name = wp_X_posts.post_name

DON'T import your backup wp_posts into multisite using the table name wp_posts! You'll overwrite a blog's content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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