MyBB Community Forums

Full Version: Can I restore user record from old backup ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

The Auto Prune plugin from DennisTT has deleted some users.
So their posts kept on the forum appears posted by Guest !

I would want restore some users with their old existing uid. (I have some
backups where these users appear.)

Can I insert manually these users into "mybb_users" safely ?
Is the "uid" field of restored user unique ? Can it be used by a new registration ?
How MyBB attributes "uid" number ?
Are the "holes" (from deleted users) filled or the uid is it chosen from the actual uid max + 1 ?

I hope you understand my question.

In one word : can I do this :
INSERT INTO mybb_users (uid, username, password, etc.....) VALUES (344, 'user_login', 'fuser_password', 'user_salt', etc......);
without corrupting the base, without crushing another user ?

Thanks.

Regards
Spyto
Essentially, when a user is deleted, they are removed from the users table. That SQL quey should work, but as always, backup the current database first before making any manual changes.

What I'm not sure of is whether or not they will still appear as a guest - you may need to recount/rebuild or run a few more queries to get everything working. Let us know how it goes...
Thanks for your answer.

These users were not deleted from ACP but by Autprune plugin !

Thus their entry was deleted of mybb_users, but their posts stayed in mybb_posts and thus shown on the forum. But naturally, the name of the author is written in black and it appears as guest (because absentee of mybb_users).

Using a query as :
select * from mybb_posts where username='deleted_login'
returns a list of posts where all uid is set to 0 (guest).

Recount/rebuild cannot work because the user is not any more in the table mybb_users !!!

My concern is to know if an uid found in a previous backup can be restored without damage.
When a new member register, how MyBB determines his uid ?
Can the uid of the deleted user be reused for him ? Or a new uid never used is always chosen ?

Regards
Spyto
A new UID is always assigned - if the last registered user has a uid of 43, the next user will have the UID of 44. They are never "recycled".

So technically speaking, you will be able to restore it without damage. Updating the posts/threads/forums will be the next task - as you're updating the database manually, there's no way of being able to update all of these at once (easily).

UDPATE mybb_posts SET uid = '???' WHERE username = 'deleted_login'

Just replace the ??? with the uid of the original user, and replace deleted_login with that user's username. You should do the same with threads and the lastpost information.
(2009-04-23, 12:11 PM)Tomm M Wrote: [ -> ]A new UID is always assigned - if the last registered user has a uid of 43, the next user will have the UID of 44. They are never "recycled".

Ok, thanks.
That means if a deleted user has the uid 21 for example, this uid=21 will never be used for a new user ?
The uid 21 remains unused for ever ?
The script will never compact the base, for sure ?
Are my three questioning true ?

Quote:So technically speaking, you will be able to restore it without damage. Updating the posts/threads/forums will be the next task - as you're updating the database manually, there's no way of being able to update all of these at once (easily).

UDPATE mybb_posts SET uid = '???' WHERE username = 'deleted_login'

Just replace the ??? with the uid of the original user, and replace deleted_login with that user's username. You should do the same with threads and the lastpost information.

Yes, I understand.
But replacing the uid one by one is a huge work?
I plan to write script to do the task. It will have to do :
1. Seach in mybb_posts (actual db) the posts with uid=0 and collect the corresponding usernames to build usernames lost.
2. Search the old backup the records of these users in mybb_users.
3. Build an "Insert into.." query list, then apply the resulting SQL to myb_users (actual db).
4. And finally update posts, threads and laspost with your query :
UDPATE mybb_xxxxx SET uid = '???' WHERE username = 'deleted_login'

Thanks for your help.
(I don't still know if I shall take the risk or if I shall abandon my lost users)