Julian
Julian

Reputation: 175

Import wordpress backup - only restore missing posts?

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!

Upvotes: 1

Views: 2506

Answers (2)

edelwater
edelwater

Reputation: 2802

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/ !!

Upvotes: 0

ajreal
ajreal

Reputation: 47321

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

Upvotes: 2

Related Questions