Actions

System Administrator's Guide/Restoring a deleted user

From Mahara Wiki

< System Administrator's Guide
Revision as of 14:21, 14 July 2011 by Richard (talk | contribs) (Created page with "== Restoring a deleted user == If you find yourself in the situation where a user has been deleted, or deletes themselves by mistake, and you have backups of your database and d…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Restoring a deleted user

If you find yourself in the situation where a user has been deleted, or deletes themselves by mistake, and you have backups of your database and dataroot, you can restore them almost to their former glory with the following steps:

First, get the database dump and site data up and running in a temporary instance, export the user to a leap2a file, and then import the leap2a file as a new user into the production instance.

On the production instance, all the user's old data that wasn't part of their personal portfolio (forum posts, feedback, etc.) will still look like it's authored by "Deleted User".

You can update all this to point at the newly imported user with the following commands in the database (assuming the new user has id 43918, and the old user is 7034:

BEGIN;
UPDATE artefact SET author = 43918 WHERE author = 7034;
UPDATE blocktype_wall_post SET "from" = 43918 WHERE "from" = 7034;
UPDATE interaction_instance SET creator = 43918 WHERE creator = 7034;
UPDATE interaction_forum_post SET poster = 43918 WHERE poster = 7034;
UPDATE interaction_forum_edit SET "user" = 43918 WHERE "user" = 7034;
UPDATE notification_internal_activity SET "from" = 43918 WHERE "from" = 7034;
UPDATE site_content SET mauthor = 43918 WHERE mauthor = 7034;
COMMIT;

The restored user will have no groups, no friends, no watchlist, no view access, and no forum subscriptions.