B2 to WordPress Migration is Not Smooth

A friend of mine wanted to migrate from an aging B2 installation to a shiny new WordPress setup. I figured it should be a simple process, given that WP was spawned from B2’s loins and all. It should have been relatively trivial – tweak some database fields, massage some data, and done. Not so fast, smartass.

Turns out that all of the tips I found were, well, a bit short. They either didn’t work at all, or sorta worked, but not enough to be useful. Crap. So, I started eyeballing the B2 schema. Turns out the biggest difference between the B2 tables and the WP tables is – wait for it – the table names. Aside from that, it’s some trivial stuff like changing int into bigint, etc…

So, here’s the process I followed. Update – this didn’t work, after all… read down to the bottom for the steps that did work.

  1. Install WordPress on my Powerbook. Create a new database for it.
  2. Import the B2 database into a new database on my Powerbook.
  3. Massage the imported B2 database – change table names to match WP, and make all fields to match what’s expected by WP. I used CocoaMySQL because it rocks so much.
  4. Dump the data from the imported/modified database.
  5. Import the mysqldump of massaged B2 data into the shiny new WP database.
  6. Verify that it’s working in WP.
  7. Mysqldump the shiny new WP database, and import it into the database server used by my friend.
  8. Cross fingers and hope it works fine on his server…

Now, why on earth doesn’t the stock “import-b2.php” file included with WordPress not just take care of this? I tried it, and it barfed miserably. I tried several other documented techniques, and they barfed equally violently. Manual tweakage appears to have worked.

Hopefully, he’ll have the blog up and running by the end of the weekend. At least he’ll be spared manual copy-and-paste operations to import the nearly 90 posts in his database, as well as the comments…

Update: OK. The manual tweak basically didn’t work after all. I ended up starting over from scratch (again), following the instructions here, followed by an additional call to update.php, and it appears all is well.

So, the real B2–>WP migration process that worked here is:

  1. Backup the B2 tables into a fresh database – call it something creative like “b2migration” or something.
  2. Install WordPress, using the “b2migration” database to store the automatically-created WordPress tables.
  3. Follow the instructions, essentially running this on “b2migration” database:
    DROP TABLE wp_categories;
    DROP TABLE wp_comments;
    DROP TABLE wp_posts;
    DROP TABLE wp_settings;
    DROP TABLE wp_users;
    RENAME TABLE b2categories TO wp_categories;
    RENAME TABLE b2comments TO wp_comments;
    RENAME TABLE b2posts TO wp_posts;
    RENAME TABLE b2settings TO wp_settings;
    RENAME TABLE b2users TO wp_users;
  4. Run /wp-admin/import-b2.php
  5. Run /wp-admin/upgrade.php
  6. Dump the tables and move them wherever you need them – you didn’t do this on your live database, did you?

3 thoughts on “B2 to WordPress Migration is Not Smooth”

  1. deities continuum-wide may sleep restfully knowing mr. Norman is keeping the datapeace on the terranet.

    i’d consider myself reasonably technically capable, at least more than the average joe blogger. nevertheless, i would have stalled at step two above. in fact, i stalled on numerous steps in numerous step-by-steps published on the web. that’s where the rocky mountain bit-bashing hero stepped in.

    trivial = running b2 import. somewhat trivial = messing with dumping the database via telnet. non-trivial = changing int into bigint. i’m sure i’m not the only one, (though i might be the only database lowbrow that reads this blog i suppose). sigh. i guess digital humanity is still too primitive for me.

    at any rate, a great big thanks to you. i promise to get everything tidied up soon.

  2. Heya, d. I would have Named Names, but didn’t want to link until you’d had a chance to setup shop first 🙂

    You’re right though – this stuff really is too primitive. Why should anyone need to go through these genuflections and incantations just to move some stuff from one blog to another?

    A Really Useful Engine would have Just Known what to do. We ain’t there yet…

    Seriously, though. If there’s anything I can do, just shout.

Comments are closed.