1

A customer claims some posts on her wordpress site went missing when she deleted user accounts. Apparently, I really cannot find these posts in the database. (I first thought maybe they were not assigned to an author)

Now I have several full backups of the site as SQL files. One missing article is in there. However, we don't know exactly which articles went missing.

I only want to restore the missing articles. Not restore the whole site. Current articles should not be deleted!

What's the best way to achieve this? Import it to a different database and somehow compare wp_posts? Thanks guys!

Julian
  • 175
  • 1
  • 2
  • 13

2 Answers2

2

You can create a temporary database,
and import your latest backup into it.
After that, do a

INSERT IGNORE INTO your_live_data.wp_posts 
SELECT * FROM temporary_database.wp_posts WHERE user_id=xxx

The trick is the IGNORE will ignore to overwrite any existing items,
which mean only insert the missing posts.

NOTE : you should replace all related tables not just wp_posts alone

ajreal
  • 46,720
  • 11
  • 89
  • 119
  • Actually did it by hand with phpmyadmin but your approach was great. – Julian Nov 28 '10 at 20:16
  • Honestly, I can't thank you enough for this. Wordpress automatically purged my trash and there are posts and pages from six months ago that I needed to retrieve from old backups. Thanks to your answer, I can. – Kit Johnson Feb 17 '16 at 10:24
0

Hmmmm.... This can get tricky because there are comments, tags, categories, etc.. etc.. but I would do it like this but have not tested it:

  1. first load the old backup in a temporary database possibly locally to speed things up
  2. then do the the reverse: delete all other users (but then the users <> the users she deleted) and accompanying posts :: theoretically this database will now only hold the articles of the deleted users
  3. export this as xml hopefully with comments etc..
  4. check the contents of the xml
  5. import in live database and assign to user N

p.s. might be worth posting on https://wordpress.stackexchange.com/ !!

Community
  • 1
  • 1
edelwater
  • 2,650
  • 8
  • 39
  • 67
  • sorry about your ClearCase question you choose to delete yesterday ( http://stackoverflow.com/questions/4303914/clearcase-delete-view-script ). I had your referenced script mixed-up with an old one I knew was incomplete (hence my initial downvote). Upon review, it was a good script and should you repost or undelete your question, I would gladly vote it up. – VonC Nov 30 '10 at 06:39
  • @VonC ow... i did not know you voted it down I just thought that it was as sign for "do not answer your own question" :) but uhmmmmm.... i can not reach the question anymore, purged? – edelwater Nov 30 '10 at 11:56
  • you can perfectly answer your own question :) I still can see the question at http://stackoverflow.com/questions/4303914/clearcase-delete-view-script . I was hoping that, as the writer of said question, you could click on that link and undelete it. If not, you can repost it. – VonC Nov 30 '10 at 12:05
  • @VonC: created new q: http://stackoverflow.com/questions/4318279/delete-clearcase-views-script – edelwater Nov 30 '10 at 20:33