Restoring a deleted topic from PHPBB.

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.

3. This will return a result that looks like this:

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.

4. At the bottom of each browse window is a “Export” link, click that, you’ll get a screen like this:

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.

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.

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:

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!

6 thoughts on “Restoring a deleted topic from PHPBB.

  1. Thanks a million! Following these instructions gave me back really important topic in my forum.

  2. Pingback: 【16時まであす楽対応】【代引送料無料】メチャカルハンディDC-360コンビ combi

Leave a Reply