Geeklog to WordPress converter

I’ve been intending to convert my blog from Geeklog to WordPress for probably the better part of a year.  I’m a stickler for preventing dataloss though, and I really wanted to keep all my old blog posts.  I searched the web on and off for a month or two looking for a way to convert the data, and the best I could find was the RSS import in WordPress.  Unfortunately, the RSS export in Geeklog sucks rocks, and even hacking on it a bit, I couldn’t get all the data out in one piece.

So I finally gave up searching and wrote my own WordPress import module for Geeklog that would copy and translate the data directly from one database to the other. It’s heavily based on the existing importer for TextPattern that’s included with the current WordPress distributions.  It imports categories, users, posts, and comments.  It also stores the Geeklog Story ID (sid) into the post metadata, for use in making the old permalinks keep working.  I have an article.php stub you can drop into your wordpress directory that takes the Geeklog permalinks and redirects to the new WordPress ones.

I’m posting this here so the next person who has to convert a Geeklog to a WordPress can save themselves a bunch of trouble. :)  It’s all been posted to WordPress’ Trac system.  If you make use of it and make any improvements to it while you’re at it, feel free to add them to that bug.

65 Replies to “Geeklog to WordPress converter”

  1. That’s one of the wonderful things about open source (software and people): someone has a problem, develops a fix, and lets the fix loose on the world (and in the relevant bug-tracker :)) so everyone else can benefit, too. Although many of us see this happening all day long in Bugzilla, there’s something “more tangible” about this wonderful way of working when one can see discreet, useful fixes hitting the “wider world” of the Internet outside of bug-trackers.

    Incidentally, your blog and mine share the same lovely theme (at least for the time being) 🙂

  2. A Couple questions:

    1. Will this work for Geeklog v1.3? Should there be any issues?

    2. What kind of redirect does this use? 301? I’ve heard google gives a penalty if the posts aren’t properly redirected? Any info?

    3. I have thousands of posts, will this time out or do something harmful to my databes?

  3. @Peter:

    > 1. Will this work for Geeklog v1.3? Should there be any issues?

    I wrote and tested it with Geeklog 1.3.9. I do not know if it works with any other version as I didn’t have any other versions to test it with. You’re welcome to try it out (it won’t do anything to the source database, so there’s nothing to lose by trying).

    > 2. What kind of redirect does this use? 301?

    That’s a good question. I basically told PHP to do a redirect, I’m not sure what it uses by default. You’re right, it should be a 301… OK, I just tested it, and it does do a 301 (permanent) redirect.

    > 3. I have thousands of posts, will this time out or do something harmful to my databes?

    It won’t do anything to your geeklog database. It may take a while to import the data into wordpress though. As far as the redirect lookups go, those should be nice and speedy up to a few million posts, MySQL is good at that stuff.

  4. One more question. I have an existing wordpress database now but my old site on the same server is on geeklog. Could running this ruin my current wordpress database? is there a safe way I should test this? Thanks for the advice?

  5. It’s always best to test it on a backup copy of the wordpress database first of course. You can take a mysqldump of the existing wordpress DB, and restore it to a different database name and test there. That said, this will add data rather than overwriting what you already have. I believe users with matching usernames will be consolidated, and it’ll probably overwrite their password with the one from geeklog in that case.

  6. Dave,

    I’m running into a problem. The plug in is using the GeekLog Database Name for the import to wordpress. IE:

    [Table ‘mygeeklogdatabasename.wp_categories’ doesn’t exist]

    By wordpress and geeklog are in two seperate databases

    Any Fix?

  7. Yeah, put the correct database names in the correct places on the form when you start. There are two separate fields for the database to look at, one for geeklog and one for wordpress.

  8. The importer I have does not ask for the wordpress database names, just geeklog:

    # GeekLog Database User:
    # GeekLog Database Password:
    # GeekLog Database Name:
    # GeekLog Database Host:
    # GeekLog Table prefix (if any):

    ?????

  9. And to clarify… the importer i have is looking to import stuff into mygeeklogdatabasename.wp_categories

    when wordpressdatabase.wp_categories is the actual wordpress location.

    I enter the correct geeklog database locations into the importer, and it obviously find that data because its trying to import geeklog categories but is unable to since it’s accessing the wrong database

  10. yeah, been too long since I actually used it. It already knows where the wp database is because it’s running within wordpress when you run it, so the gl one is the only one it should be asking for. What versions of Geeklog and WordPress are you using?

  11. I’m using geeklog 3.1 but thats not the issue because the error messages reference the data that needs to be moved

    my wordpress is 2.0.5

    I can tell you 100% that it is trying to import the geeklog data to me geeklog database

    [Table ‘mygeeklogdatabasename.wp_categories’ doesn’t exist]

    obviously .wp_categories doesn’t exist in mygeeklogdatabase because thats a whole nother database from my wordpress database

    So what can i do to change the script so i can import into the wordpress database?

  12. no idea. It worked fine for me. The script doesn’t do any direct database access to the wordpress database, it uses wordpress’ library routines for all the data insertion. So wherever the wordpress config is pointed at probably.

  13. hmmm well i want to use your script but it doesn’t look like that’s going to be possible because what i’m telling you is not usser error, the script is trying to import into the geeklog directory not wordpress

  14. Peter:

    I had the same issues as you, but eventually found a post on the WP Codex that helped greatly: merge the two databases first, then run the script. I imported my GL database into the WP database, then when the script asks for the name of your GL database, give it the name of the WP database.

    Bingo! Then just delete the GL tables when you’re done.

  15. Script improvement: I wanted to maintain the “Read more…” breaks from Geeklog. So just above this line…

    $Body = $introtext.$bodytext;

    Add this line:

    $more = (strlen($bodytext)) ? ‘‘ : ”;

    And then change the $Body line to this:

    $Body = $introtext.$more.$bodytext;

    This will force the importer to respect those Geeklog stories that were originally split in two parts.

    Thanks so much for this importer; you saved me hours of manual labor that I’d volunteered to do for a buddy!

    -rob.

  16. Interesting. Mine were in two separate databases when I did it. But they were both on the same mysql server. Maybe that’s the issue. I did do a dump of the original database and restore it to the new server along side the wordpress one before running it.

  17. I had the same setup — both databases were running on the same machine under the same MySQL server (same user accessing both, in fact). But when I tried to import from Geeklog, I had the exact results shown above — the table names for the Geeklog tables had “wp” in their names. When I merged the databases, it worked as expected.

    I wonder if it might have to do with PHP versions? I was using PHP5 on Apache 1.3.33.

    -rob.

  18. Hi Dave,
    Thanks for sharing this useful info. I’ve been on GL v1.4.1 for a while and I can’t take it anymore. I’m tired of trying to find the right place to hack in GL’s codebase just to make it do some basic things that other blogs can do.

    However, I’m not a php/MySQL engineer, nor do I want to be one. I just want to get off of GL and get onto a more friendly platform.

    Question 1: Do you think WP is a “best of breed” alternative? Can I use it (say, with Feedburner) to send out new posts via email automatically?

    Question 2: Would you be willing–or anybody else–to do the migration for hire?

    Any suggestions would be most appreciated!

  19. Chris: in regards to question 1, I can only say that I’m satisfied with it so far. I haven’t gone out of my way to research what’s out there, but I had several friends that liked WP, and their blogs looked nice, to I used it. 🙂

    For question 2: as much as I’d love to, I find myself already running way short on time to keep up with the stuff I’m already paid to do, so I’d have to decline. 🙁

  20. Hey Dave, Thanks! Worked great mostly for my conversion except for post titles that have a ‘ in it… worked on geeklog 1.4.x and wordpress 2.1.3 for those interested.

  21. OK, thanks Dave.

    If anybody else reads this and is willing to do a conversion for me for hire, please write me at chris dot nelder at idiotwind dot net.

    Thanks!

    –C

  22. wow. thanks for posting this. it’s just what i’ve been looking for. i’ve been “locked in” geeklog for a long while and i can’t wait to transfer over to wordpress.
    i’m probably going to take my time and really look into how to get migrated over properly but this definitely looks like the answer to my problems. thanks again.
    i’ll let ya know how it goes.

  23. Hi. Here’s a question. I found this while looking for something to convert FROM WordPress TO Geeklog but all I’m finding is stuff about people converting the other way round.

    I’ve been impressed with geeklog although I admit I’ve only had a few hours’ play… what have I missed?

    Thanks for any advice offered.

    Bruce

  24. For me it was the ease of posting. It’s slightly more difficult to post a new article in Geeklog. And necessarily so, because Geeklog is intended to be a full website CMS rather than blog software. WordPress was designed to be a blog, so that’s what it’s good at. If all you’re doing is a blog, Geeklog is kind of overkill. But if you’re doing a full website with news and articles and whatnot, Geeklog is great.

  25. Oh, one other thing I like about WordPress is getting an email every time someone posts a comment. I never managed to get Geeklog to do that (at least not in the version I was running at the time – I’d be surprised if that hasn’t been added in a newer version since then)

  26. Hello Dave,

    I hope you read this.
    I just imported all articles and users, all done well.
    Works like a charm.

    But i was using a different permalinks in geeklog made bymyself using .htaccess mod rewrite.

    My links were like instead of standar geeklog

    /article.php?story=name-of-article

    i did rewrite to show

    /articles/name-of-article.html

    So…my question is…
    How can i change you article.php file to redirect these links too??
    i already made a test and it doesn’t redirect.

    I don’t move permanently my website…i need to solve this problem first.

    Thanks in advance, any help is welcome.

  27. hirocaster: I wouldn’t really be sure without seeing it. Basically, you would need a RewriteRule in your .htaccess to point /article/ at your article.php file, then you would need to change article.php to look up the title instead of the old sid from geeklog. Depending on the formatting of the title, you may need to adjust the import script to save geeklog’s version of the title slug as a meta field (like I did with the sid value) and look that up instead, but if the title slug imports intact in wordpress you can probably just look up wordpress’s version.

  28. Success!

    Thank you, Dave, for creating and posting this. It works great and is much cleaner than I probably would have made it for my own purposes.

    For the record, I migrated a Geeklog 1.3.11 install to WordPress 2.2.2 using your script. This was running on MySQL 4.1.20 and PHP 5.0.4 on a CentOS 4.5 system. Everything just worked!

    One note, as I was a bit ignorant of WordPress; users need to copy the “geeklog.php” file into the “{wordpress}/wp-admin/import/” directory in order to use it. It is accessed from the WordPress admin tool’s “Manage -> Import” menu.

    Very simple, but that took me a bit to figure out.

    Thank you again!

  29. Worked for me, going from Geeklog 1.4 to WordPress 2.2. I did get the same error that Peter got, so I imported the GL data into my WP database and just pointed the importer to the WP database. Worked fine after that.

    Thanks!!!

  30. I also merged the databases and everything almost worked perfectly. The only problem I had was that all of my embedded pictures seemed to disappear. Any ideas on how to proceed with fixing that?

    For the record, I imported into WP 2.3.1 from GL 1.4.

    Thanks for writing a great script — you saved me a ton of heartache because this is a blog that is fairly popular and getting it onto the new platform before dinner (after work) is an awesome piece of coding on your part.

  31. I never got as far as fixing images… I only had two at the point when I moved my data over, and I just fixed them by hand. It would involve some URL detection, matching img src links that have your site’s prefix or match Geeklog’s image directory, then snagging the file, putting it where WordPress expects it, and rewriting the URL within the body of the post.

  32. Where to start? I am trying to get data imported from an old 1.3.11 geeklog site but I cannot seem to figure out where to start. I have geeklog.php and article.php, a brand-new wordpress installation. What’s the next step? Simply visiting the wordpress/geeklog.php doesn’t seem to work. Should I drop the geeklog.php/article.php into the geeklog site and go from there?

    /john

  33. ok, figured out what to do with geeklog.php, you add it to the /wp-admin/import and then manage -> import. however… it only imported my categories and did not grab the articles…. so one must assume, do something with article.php to get that accomplished. working on that now. using this blog comment as a helper for future users. please input if you know something i am missing.

    /john

  34. ok, figured out the wp-admin/import thing… put geeklog.php in there…. but, i can’t get the stories in GL to import into the new wordpress database and i have no clue what to do with the article.php.

    help?

  35. article.php isn’t needed as part of the conversion process. You use that after the fact if you want your old permalinks to keep working.

    You did find the correct location for the geeklog.php script. Did it tell you that it finished? There’s several steps to it (users, categories, articles, comments), and all of them need to complete, one at a time, you’ll need to confirm each one, and it’ll tell you that everything is done after the last one.

    Do note the issues mentioned on the bug report on wordpress’ site about memory, make sure you’re not running out of memory before it finishes.

  36. I am not seeing any buttons other than “Categories”, the other buttons in the geeklog/import (geeklog.php) seem to be missing.

    /john

  37. The button for each thing to be imported is at the bottom of the screen with the results of the previous thing you imported. There should be a button at the bottom of the results screen from importing the categories to go on to the next thing.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.