1

One of our users permanently deleted a lot of content - about 600 posts and pages on a site with several thousand posts. We have a backup of the database before this happened but can't just replace the existing database with the backup because of subsequent changes (ie we didn't spot this promptly).

What would be the easiest way to import and append the old records?

  • For me, using the backup DB will be only way if the post has deleted permanently. If the post are in draft you can restore back. – Aftab Aug 25 '16 at 7:31
  • The take away from this, is that you don't have a good backup policy. In your defense, I am not familiar with any current backup tool that does it totally right. – Mark Kaplun Aug 25 '16 at 7:49
  • Just a quick thought, might be easier to go with backup db and import newer posts to it to keep ID collisions from happening – Tom Aug 25 '16 at 8:19
  • Unfortunately this happened just before a large revamp which included changing taxonomy, plugins, templates, etc. Going back is not an option. – robin Aug 25 '16 at 8:27
0

I never personally tried it, but maybe mysqldbcompare is worth a shot.

Taken from this StackOverflow answer

mysqldbcompare --server1=A --server2=B --changes-for=B --difftype=sql

Should generate SQL statements that will make server B match server A.

If you check the MySQL doc, you can run from same server by only specifying the --server1 option. I would test it on a local server with backups of the current DB and the old DB (before the delete)

0

In your PC, when you delete files from the trash bin, how do you restore them back when you discover it was a mistake? maybe if you have a backup it will be possible, but it is for sure not easy as you can't just restore the whole hard drive that have other modifications. Same applies here.

You need to spin a new wordpress with the backup, locate the relevant posts (maybe with the help of the DB compare that @bynicolas suggested) and just copy paste the content. You might be able to just try to merge the DBs, but that might be risky depending on whether setting that apply to content on save were changed between the backup time and the current DB.

  • Yup. This is plan B if there isn't already a solution someone else has hacked eg. this. Building it is a pain but perhaps no more painful than copy/paste. – robin Aug 25 '16 at 8:13
  • @robin, if you can organize it in CSV forn, maybe one of the CSV importing plugins will help, but in a mature site you probably have more settings than just content per post, like featured image, and other settings that are stored in the meta – Mark Kaplun Aug 25 '16 at 8:41
  • Thanks. Yeah I've been looking at those. It's kind of a hybrid solution: less work than doing your own programme but requires more work to clean up the imported records. – robin Aug 25 '16 at 8:46

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.