MyBB Community Forums

Full Version: Restore deleted posts from old backup
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
A user or a mod (dont know) deleted all his posts Sad
Is there any hope to restore thoses deleted posts from an old database backup?
If on the old database backup the posts are there, then yes. I recommend you set it so only admins can delete posts in the future, mods can hide them anyway. Smile

Also, I don't recommend going to an old database backup, your entire forum may lose posts.
Thanks
But I want a way to retore deleted post WITHOUT loosing anything
Sorry, this really isn't possible. Undecided
Very sad to hear it
Can I restore at least ONE thread by inserting it into database via a sql query
Because, that user deleted a thread and all valuable posts and replies within this thread have been deleted as well Angry
(2011-01-24, 08:36 PM)Derek M. Wrote: [ -> ]Sorry, this really isn't possible. Undecided

Um, yes it is. You are able to restore just 1 table.
(2011-01-24, 09:12 PM)pyridine Wrote: [ -> ]
(2011-01-24, 08:36 PM)Derek M. Wrote: [ -> ]Sorry, this really isn't possible. Undecided

Um, yes it is. You are able to restore just 1 table.
You can restore 1 table. But he wanted to put back in just that user's posts.

Yes, and you can do that.

Create a totally new database, import the backup to it. Then, run these queries:

INSERT INTO `dest_db`.`mybb_posts` SELECT * FROM `new_db`.`mybb_posts` WHERE `uid` = 'X';
INSERT INTO `dest_db`.`mybb_threads` SELECT * FROM `new_db`.`mybb_threads` WHERE `uid` = 'X';

Four things to do.

Backup your current posts and threads tables first.
Change dest_db to the name of your normal database.
Change new_db to the name of the database you just made.
Change the X to the ID of this user.

These queries will reimport the threads and posts made by this user. I just need to add another query to add all the posts inside threads this user created
Thanks a lot MattRogowski
Now there is a hope
But when I run:
INSERT INTO `mybb16`.`mybb_posts` SELECT * FROM `test`.`mybb_posts` WHERE `uid` = '2196'
it returns
#1136 - Column count doesn't match value count at row 1
Any idea?
It seems that the posts table in your main database has additional columns to the posts table in your backup. Have you added any plugins since making that backup that may have added a column to the posts table??

Try running these queries instead. I've already made the edits you need for you.

INSERT INTO `mybb16 `.`mybb_posts` SELECT `pid`, `tid`, `replyto`, `fid`, `subject`, `icon`, `uid`, `username`, `dateline`, `message`, `ipaddress`, `longipaddress`, `includesig`, `smilieoff`, `edituid`, `edittime`, `visible`, `posthash` FROM `test`.`mybb_posts` WHERE `uid` = '2196';
INSERT INTO `mybb16 `.`mybb_threads` SELECT `tid`, `fid`, `subject`, `prefix`, `icon`, `poll`, `uid`, `username`, `dateline`, `firstpost`, `lastpost`, `lastposter`, `lastposteruid`, `views`, `replies`, `closed`, `sticky`, `numratings`, `totalratings`, `notes`, `visible`, `unapprovedposts`, `attachmentcount`, `deletetime` FROM `test`.`mybb_threads` WHERE `uid` = '2196'; 
Pages: 1 2