MyBB Community Forums

Full Version: How to Merge in old deleted Users from old SQL backup?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
There's a forum I admin and for whatever stupid reason the previous admin had purged thousands of members. I have the database backup before the purge.

It's been about 6 months since then but I want to merge in users from the old database into the new one except where any conflict exits. EG if a current person registered with the same username as someone had in previous backup then that old account will not be imported.

Is there a way to do this and if so how?
Reason being I've had a few members who complained and want their old accounts back but I'd rather do this in bulk instead of remaking a ton of accounts manually.

Any help is appreciated! thank you!
Import the users table into mysql as something like mybb_users_old. Construct a query like this...

insert into mybb_users (col1, col2, col3)
select col1, col2, col3 from mybb_users_old
where not exists (select 1 from mybb_users as mybu where mybu.username=mybb_users_old.username);

For the column specifications, you will want to use all columns except the UID column. This will be autogenerated on insert.
thank you for this Smile