0

A few weeks ago a site admin canceled a user account on one of my Drupal 7 sites and clicked on "Delete the account and its content." That user had created about half the content on the site in different content types and uploaded files.

So we lost about half our content.

I have backup (a mysql dump) of the site from before account was removed and all the uploaded files, and I'm sure the user wasn't active in the time between the backup and the removal.

Is there an easy way to recover the content from that one user? I cannot just restore the database from the dump, since that will wash away any changes since then.

2
  • 1
    I've been there. Scrum master thought he'd help out a few days before launch, did what your admin did, and didn't tell anyone. Day before launch, we found out a hundred or so pages were missing. Suffice to say, and in spite of having several very experienced Drupal devs available to help, we didn't find an easy way to recover. It was a toss up between manually re-entering the content, or scripting a migration. We went with manual re-entry and a lot of coffee.
    – Clive
    Sep 26 '19 at 19:23
  • I was afraid of that. But I don't think we have time or money for re-entry.
    – Michael
    Sep 26 '19 at 19:31
2

It depends on how complicated your content/site structure is, authored by the user account that got deleted, but it can be fairly easy if it's just nodes and sum such content.

Use which ever migration method you're most comfortable with. Migrate module is popular, but Feeds may be more user-friendly? Don't hang on module reviews here ;)

One way to go about it is to create a separate dev instance of your site by copying the live Drupal folder, and restoring the database backup that contains your deleted user and content. Like a time machine viewing your site at a moment in the past :)

You can use Views to list all content from that user, export it as CSV, or some other parsing case. Views gives you a nice overview of what's there so you can check you got everything. You can output post times, statuses, references to other entities...

Then build Feeds importer for what you exported. Test the import on yet another dev instance of your site, the copy of the current db. TEST everything thoroughly before importing to a site that matters, this should be obvious. Migrations are notoriously tricky and long affairs.

You could go as far as to restate the user with account history etc with some more magic, but it seems you only need the content so it will probably easier to just assign authorship to another user or anonymous if it doesn't clash with permissions, or create a completely new user, you can name it the same as the old one but the ID will be different.

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.