Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: Database: MySql
 How to restore a single topic from backup?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

sikandar
Junior Member

Pakistan
135 Posts

Posted - 26 September 2007 :  22:44:29  Show Profile

Hi,
I want to restore a topic from backup with all replies as it is deleted accidentally. Please guide me how can I restore or if there are any extraction queries then please let me know.

Thanks

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 27 September 2007 :  04:51:14  Show Profile  Visit MarcelG's Homepage
This is not exactly an easy task.....not a simple 'howto'.
What DB are you using?

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 27 September 2007 :  05:11:33  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
Since this is posted under mysql I guess that's the db used. It wouldn't be that hard if you have access to the backup files.

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 27 September 2007 :  05:23:08  Show Profile  Visit HuwR's Homepage
I think a mod has been posted that does this, try searching in the MOD forums
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 27 September 2007 :  06:41:28  Show Profile  Visit AnonJr's Homepage
There are two MODs that I know of, but they are for un-archiving topics, not recovering deleted topics... unless I've missed something. I do know that this discussion has happened a few times before where you and Rui outlined all the steps with all the disclaimers etc. - just can't seem to find it at this point in time. Maybe when I get my first coffee of the day....
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 27 September 2007 :  06:50:00  Show Profile  Visit HuwR's Homepage
no. my fault, I misread the question sorry
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 27 September 2007 :  06:55:59  Show Profile  Send ruirib a Yahoo! Message
From a practical point of view, the question is rather easy, admiting that archive tables and live tables have exactly the same columns in the same order!. If that is the case, this set of queries should work:

INSERT INTO FORUM_TOPICS 
   SELECT * FROM FORUM_A_TOPICS WHERE TOPIC_ID=xxx

INSERT INTO FORUM_REPLY
   SELECT * FROM FORUM_A_REPLY WHERE TOPIC_ID=xxx

DELETE FROM FORUM_A_REPLY WHERE  TOPIC_ID=xxx

DELETE FROM FORUM_A_TOPICS WHERE TOPIC_ID=xxx 


Update counts should be run after this.

These are valid only for the conditions stated above. If the column order is not identical in the live and archive tables, the SELECT statements should explicitly pick the columns from the archive tables in the order they are present in the live tables. I also advise running the DELETE queries if and only if the previous two queries are executed with success.

Transactions won't normally be possible since most MySQL Dbs use MyISAM tables, which do not support them. If this wasn't the case, then all this should be run inside a transaction, which would ensure success or failure without the risk of unrecoverable data loss.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 27 September 2007 :  08:29:51  Show Profile  Visit AnonJr's Homepage
Based on the original post, I think he deleted the topic - not archived it - and he wants to restore it from a backup. Again, I'm not a morning person and I'm just now getting my coffee so I could be mistaken.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 27 September 2007 :  08:43:54  Show Profile  Send ruirib a Yahoo! Message
Yeah, it seems you're right, Mark. I guess importing the data to a "new table" could be the option, and then use a strategy like the one shown in my two insert queries would be the answer.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

sikandar
Junior Member

Pakistan
135 Posts

Posted - 27 September 2007 :  22:30:02  Show Profile
Thanks to all of you. Well I have backup from where I have to restore the topic. Now what I will do as explained by ruirib will restore these two tables with different names and then will use two insert queries. Hope this will resolve the issue so let me try and will get back to you with my findings.

Thanks
Go to Top of Page

sikandar
Junior Member

Pakistan
135 Posts

Posted - 28 September 2007 :  02:22:32  Show Profile
The info provided by ruirib really helped as I extracted rows from the backup file for these two tables and just insert those in the tables. It solved the problem so basically here tables to be addressed were important for me. Have a nice time.

Thanks
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 28 September 2007 :  02:55:43  Show Profile  Send ruirib a Yahoo! Message
Glad you sorted it.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.86 seconds. Powered By: Snitz Forums 2000 Version 3.4.07