MyBB Community Forums

Full Version: Reinsert Users Deleted
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
On 8/11 there was a whoops made that wasn't caught until now. 12 accounts were deleted by accident. I need to get these accounts back.

I have backups ran automatically every other day so I have a backup from 8/11 (the date it occurred) and one from 8/9 (two days prior). However, I can't tell what time the backup on 8/11 was made because the file name is backup__20230811_074018_sd2NXXyZSzjVBhUZ.sql.gz and I'm not certain if 074018 is the timestamp (if so its from 1970 lol)?

I'm also not sure how to grab the deleted accounts and reinsert ONLY them into the database alongside their userfields. I think I can figure out how to manually reattach their now unregistered account posts to their UID.

What would be the best approach to take with this? I am under the impression I should create a new database and import the backup to it so that I can access the information from the deleted users. But I'm not sure how I would download these users and import them to the live database?




Alrighty, so I did end up solving this on my own though I'm sure I did this the most complicated way possible. But it worked so just in case in the future someone has something similar happen here is what I did to put these accounts back into the database and reattach their posts/threads to their account.

Backup Upload & Export of Data
I ended up uploading the backup from 8/11 and checked to see if it had all of the accounts missing. It did so the backup ran before the accidental deletes.

I created a new database table in phpMyAdmin and then imported that backup.

One by one I download the exported copy of the users that were deleted from the users AND userfields tables.

Using users & userfields Exports To Insert
I opened the exports for users and userfields using VS Code. From here I found this comment in the .sql file.
--
-- Dumping data for table `prefix_userfields`
--
Below this was the INSERT INTO code. I literally copied it for each user from each users and userfields export download and ran the SQL query in the live database.

It worked, all accounts were back with their userfields.

Fixing Posts/Threads UID
I literally ran the two following queries thanks to Matt's Common SQL queries and how to run them tutorial thread.
UPDATE `prefix_threads` SET `uid` = '#' WHERE `username` = 'Username';
UPDATE `prefix_posts` SET `uid` = '#' WHERE `username` = 'Username';