SMF: Recover deleted topic

Important: you must have a backup of the database with deleted topic. If not, you might as well skip this post.

Instruction here is based on SMF V1.1.x and uses phpmyadmin. It’s a free browser based MySQL administration tool. But if you’re a MySQL expert or you’re using a different database, you can still work out SQL and commands.

Restore backup

Create a dummy database (make sure it’s not the same name as the one used by your production forum!) and restore the backup database.

Locate the missing topic

You need to know the topic ID. If not, look for it via smf_messages table. you can look up subject and / or body columns. once found, note the value for column ID_TOPIC.

Extract missing topic

Assuming the topic ID is 100.

From the backup database, click SQL link and run the following SQL queries (one by one):

 select * from smf_messages where ID_TOPIC = 100 
 select * from smf_topics where ID_TOPIC = 100 

For each of the result, click Export link from bottom of the result. Do not click the export link on top of the page!

You’re now at export page. From export box, select SQL. Uncheck ‘save as file’. Click Go.

You should see various SQL statements. Just copy the insert statements.

Now go to the production database. Open SQL window. Paste the above insert statement and execute.

Check your forum

The topic should be back!

Leave a Reply

Your email address will not be published. Required fields are marked *