Importing from another S9y?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
jbalcorn
Regular
Posts: 5
Joined: Fri Oct 31, 2003 6:00 pm
Location: Cleveland Heights, OH
Contact:

Importing from another S9y?

Post by jbalcorn »

I want to combine 2 S9y blogs into one. We have nice imports for a lot of different blogs, but not one for S9y itself!

I want to keep comments, trackbacks, back end formatting, etc. RSS import will get the data in but the actual code of the entries will be changed.

Is there a clean back-end way to combine the databases? What are my options?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Importing from another S9y?

Post by garvinhicking »

I've answered this yesterday on IRC a bit, so just to have posted it here:

http://nopaste.php-q.net/131295

The basic workflow is this:

1. Use a mysql_query and loop on all serendipity_entries. Inside the loop of each entry, insert the entry into your new table. Get the last_isnert_id and store a cache to the current looped entry id and how its new ID is.

2. Loop through the categories and insert them the same way. Again store a reference which new ID the category has in the new table. You need those caches to later reference the new ids for categories and so on.

3. Loop through the entrycat table. Do not insert the old entryid+catergoryid reference, but instead use those cache references for insertion

4. Loop through the entryproperties table and do the same with the cache reference for the entryid

5. You may need to also fetch the authorids and loop on them if they are different from your new blog

Justin said on IRC to share his script once he's finished. :)

Regards
garvin
jbalcorn wrote:I want to combine 2 S9y blogs into one. We have nice imports for a lot of different blogs, but not one for S9y itself!

I want to keep comments, trackbacks, back end formatting, etc. RSS import will get the data in but the actual code of the entries will be changed.

Is there a clean back-end way to combine the databases? What are my options?
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
jbalcorn
Regular
Posts: 5
Joined: Fri Oct 31, 2003 6:00 pm
Location: Cleveland Heights, OH
Contact:

Script almost done

Post by jbalcorn »

I'm about 90% done with the script, it's turning out much more complex than i at first thought, but it should be pretty robust at the end.

Today or tomorrow I'll post it.
jbalcorn
Regular
Posts: 5
Joined: Fri Oct 31, 2003 6:00 pm
Location: Cleveland Heights, OH
Contact:

Here's the script

Post by jbalcorn »

I used it to combine two blogs into one, bringing all the data from http://jalcorn.net/politics/ into http://jalcorn.net/weblog/ (I haven't pulled the trigger yet, but I tested it all into a test blog)

http://jalcorn.net/weblog/archives/555- ... cript.html
jbalcorn
Regular
Posts: 5
Joined: Fri Oct 31, 2003 6:00 pm
Location: Cleveland Heights, OH
Contact:

Re: Here's the script

Post by jbalcorn »

jbalcorn wrote:I used it to combine two blogs into one, bringing all the data from http://jalcorn.net/politics/ into http://jalcorn.net/weblog/ (I haven't pulled the trigger yet, but I tested it all into a test blog)

http://jalcorn.net/weblog/archives/555- ... cript.html
Just an update; I had an interesting problem in that the template I used is an old 0.7-version one, and it caused problems with the categories. The script itself was fine, the template was messed up.

So I've run the script on my production blog and it worked fine.
Post Reply