Restore hard deleted topic from backup

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Suggested Hosts
Foxina
Registered User
Posts: 27
Joined: Mon Jan 03, 2022 9:20 am

Re: Restore hard deleted topic from backup

Post by Foxina »

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
mysqldump phpBBdatabase phpbb_bookmarks --no-create-info --where="topic_id=4330" --complete-insert >> recordfile
mysqldump phpBBdatabase phpbb_poll_options --no-create-info --where="topic_id=4330" --complete-insert >> recordfile
mysqldump phpBBdatabase phpbb_poll_votes --no-create-info --where="topic_id=4330" --complete-insert >> recordfile
mysqldump phpBBdatabase phpbb_attachments --no-create-info --where="topic_id=4330" --complete-insert >> recordfile
#mysqldump phpBBdatabase phpbb_drafts --no-create-info --where="topic_id=4330" --complete-insert >> recordfile
mysqldump phpBBdatabase phpbb_log --no-create-info --where="topic_id=4330" --complete-insert >> recordfile


# need to get all post_ids which are related to the topic 4330
post_ids=$(mysql phpBBdatabase -N -e "SELECT GROUP_CONCAT(post_id SEPARATOR ',') FROM phpbb_posts WHERE topic_id = 4330;")

# to populate phpbb_search_wordmatch and phpbb_reports tables
if [ -n "$post_ids" ]; then
# mysqldump phpBBdatabase phpbb_search_wordmatch --no-create-info --where="post_id IN ($post_ids)" --complete-insert >> recordfile
mysqldump phpBBdatabase phpbb_reports --no-create-info --where="post_id IN ($post_ids)" --complete-insert >> recordfile
else
    echo "No post_id values found."
fi

### END
So, if I comment out the phpbb_drafts and phpbb_search_wordmatch, I can then run the file against a backup copy of the current phpBBdatabase without any errors.
The deleted topic is also available.

Not found by phpBB Native Fulltext search though.
Trying to rebuld the index from ACP gui in test environment crashes.
Probably would need a cli option for that.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3949
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: Restore hard deleted topic from backup

Post by Kailey »

Foxina wrote: Sun Apr 28, 2024 2:03 pm Probably would need a cli option for that.
Unless someone wants to backport it, that option won't appear until 4.0.
https://github.com/phpbb/phpbb/pull/5439
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders

Return to “phpBB Discussion”