News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Move Topic Cross Forum

Started by heavyccasey, April 03, 2009, 08:34:36 AM

Previous topic - Next topic

heavyccasey

Is there a way to nicely more topics across forums? I had this old forum whose server died, so I made a new forum and restored an incomplete backup. But now, digging through my files, I found a complete backup! The backup is in SQL.

I was thinking that I could create another forum, restore the backup, and then somehow move the topics cross-forum with a custom script. Possible, yes/no? Thanks.

Aleksi "Lex" Kilpinen

Are you talking about transferring 1:1 or merging 2:1 ?

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

heavyccasey

These two are technically the same forum, i.e., the same members. The difference is that the first backup has some topics the second doesn't, and the second backup has some topics the first doesn't. Plus, I want to selectively transfer so I don't have duplicates or spam.

Aleksi "Lex" Kilpinen

So merging posts from 2 different smf databases, without mixing any other info.
I'm sorry to say I haven't the foggiest idea if and how that could be done.
Have you tried searching the forun on merging databases or merging forums?
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

heavyccasey

I searched the forum and found little information. I'm not 100% sure, but INSERT - SELECT looks like the way to go?

heavyccasey

Okay, it worked. Here's how.

1) Open your backup with a text editor that can handle large files, like Jujuedit.

2) Edit everything out except for the smf_topics and smf_messages table.

3) Using this Python script, replace smf_ with smfold_
On Windows:
bigreplace.py smf_ smfold_ < old.sql > new.sql

4) Import it into MySQL:
On Linux:
mysql -u name -p databasename < new.sql

5) Find the topic IDs of the topics you'd like to transfer.

6) SQL:
INSERT INTO smf_messages (ID_MSG, ID_TOPIC, ID_BOARD, posterTime, ID_MEMBER, ID_MSG_MODIFIED, subject, posterName, posterEmail, posterIP, smileysEnabled, modifiedTime, modifiedName, body, icon) SELECT ID_MSG, ID_TOPIC, ID_BOARD, posterTime, ID_MEMBER, ID_MSG_MODIFIED, subject, posterName, posterEmail, posterIP, smileysEnabled, modifiedTime, modifiedName, body, icon FROM smfold_messages WHERE ID_TOPIC = {topic id goes here}

7) SQL:
INSERT INTO smf_topics (ID_TOPIC, isSticky, ID_BOARD, ID_FIRST_MSG, ID_LAST_MSG, ID_MEMBER_STARTED, ID_MEMBER_UPDATED, ID_POLL, numReplies, numViews, locked) SELECT ID_TOPIC, isSticky, ID_BOARD, ID_FIRST_MSG, ID_LAST_MSG, ID_MEMBER_STARTED, ID_MEMBER_UPDATED, ID_POLL, numReplies, numViews, locked FROM smfold_topics WHERE ID_TOPIC = {topic id goes here}

8 ) Repeat 6 & 7 for all the topics you'd like to transfer. (I just decided to transfer the notable ones.)

Obviously replace smf_ with your database prefix. You can also probably replace the WHERE clause in the two queries with WHERE ID_TOPIC IN (topic1, topic2, topic3).

Hope it helps someone!

Advertisement: