This section contains detailed articles elaborating on some of the common issues phpBB users encounter while using the product. Articles submitted by members of the community are checked for accuracy by the relevant phpBB Team. If you do not find the answer to your question here, we recommend looking through the Support Section as well as using the Site Wide Search.

Recover a deleted topic.

Description: How to recover a deleted topic, even ones including attachments.

In Categories:

Link to this article: Select All
[url=https://www.phpbb.com/support/docs/en/3.0/kb/article/recover-a-deleted-topic/]Knowledge Base - Recover a deleted topic.[/url]

To anyone who runs a forum based website, there will come a time when you accidentally delete, or a moderator will delete a topic that should not have been deleted.
This is devastating to a forum running on PHPBB since there is no “undo” or “trash can”, once it’s deleted, the posts/topic are dropped from the sql database, and the attachments (if any) are removed from the attachment directory. They are truly “gone”.

Now, lets assume you have server backups, as you should. Also, this is a complicated process and should only be done in extreme cases. (like when a 63 page topic with 942 posts gets accidentally deleted by a moderator)

The requirements:
First, you’ll need the sql database backup, if there were any attachments with the topic, you’ll need a web file backup as well.
Second, you’ll need to know the ID of the topic you’re trying to restore. Let’s say for example the topic_id was 26446.
Third, you’ll need either a empty database and/or a virtual environment.

Lets begin:
1. Extract your sql backup into an empty database. I’ll be using phpmyadmin for this example.
2. Go to search, enter your ID number as the search value, exact match, select all tables, and specify “topic_id” for the inside field.
Image
3. This will return a result that looks like this:
Image
3. There are only a few tables here that are required: “phpbb_attachments”(if you have any), “phpbb_posts”, and “phpbb_topics”. Click browse on each of these, being sure to open them in a new tab/window.
Image
4. At the bottom of each browse window is a “Export” link, click that, you’ll get a screen like this:
Image
UNCHECK THE STRUCTURE BOX! You just want the data. You also want to save this as a file. Repeat these steps with the two other tables.
5. Now switch over to your live/production database, go to the “Import” tab, and upload the 3 files to it.
Image
Assuming there are no import errors, you’re done importing the sql data! The restored topic should be visible and functional again, the only thing missing at the moment should be attachments.

Now lets assume you have attachments, as a good portion of topics do:

1. Open the phpbb_attachments sql file that we made in step 4 with a text editor.
Image
2. I know this looks crazy, but trust me, it’s easier then you think. All we care about is the large random string in the middle: “32106_0ffb39ce936e4c0b5237c01859df9041″ This is the “image” after phpbb converts it.
3. Open your web file backup to the directory where attachments are stored, and search for the string. You should get something like this:
Image
4. FTP the file, and the thumb file (if it exists) to your live/production attachment file directory. Repeat for each file in the phpbb_attachment table.

THAT’S IT! Thank god it’s over… Be more careful next time!

Source: http://jasonhilton.us/main/?p=69