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.
- Install WordPress on my Powerbook. Create a new database for it.
- Import the B2 database into a new database on my Powerbook.
- 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.
- Dump the data from the imported/modified database.
- Import the mysqldump of massaged B2 data into the shiny new WP database.
- Verify that it’s working in WP.
- Mysqldump the shiny new WP database, and import it into the database server used by my friend.
- 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:
- Backup the B2 tables into a fresh database – call it something creative like “b2migration” or something.
- Install WordPress, using the “b2migration” database to store the automatically-created WordPress tables.
- 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;
- Run /wp-admin/import-b2.php
- Run /wp-admin/upgrade.php
- Dump the tables and move them wherever you need them – you didn’t do this on your live database, did you?