Returning to this recurring issue with a new solution.
Before applying it to the production database, all kind advises welcome.
Reference:
3.2 Support Forum "restore a single topic from backup"
In this old topic, @stevemaury suggested to get the data for the deleted topic from a full backup like this:
SELECT * from phpbb_posts WHERE topic_id = X;
SELECT * FROM phpbb_topics WHERE topic_id = X;
SELECT * FROM phpbb_topics_posted WHERE topic_id = X;
SELECT * FROM phpbb_topics_watch WHERE topic_id = X;
SELECT * FROM phpbb_topics_track WHERE topic_id = X
And then restoring the lines to production, with update clauses.
I found this a bit complicated, but the SELECT statements from above useful.
Came up with this BASH script.
Code: Select all
#!/bin/bash
# Get data for topic 4330
mysqldump phpBBdatabase phpbb_posts --no-create-info --where="topic_id=4330" --complete-insert > recordfile
mysqldump phpBBdatabase phpbb_topics --no-create-info --where="topic_id=4330" --complete-insert >> recordfile
mysqldump phpBBdatabase phpbb_topics_posted --no-create-info --where="topic_id=4330" --complete-insert >> recordfile
mysqldump phpBBdatabase phpbb_topics_watch --no-create-info --where="topic_id=4330" --complete-insert >> recordfile
mysqldump phpBBdatabase phpbb_topics_track --no-create-info --where="topic_id=4330" --complete-insert >> recordfile
mysql -u root -p phpBBdatabase < recordfile
### END
As it is, the backup which contains the deleted post is for 3.2.11 and by the time the deletion was noticed, we had done an upgrade to 3.3.11.
In any case, as I tested it, the topic is restored correctly even to 3.3.11.
Question is, am I missing something?
These five tables enough?
Test environment did not break at least, but I am hesitating to run this against production.
The above method of course requires, you have full terminal access to your board system and an test environment.