B2 to WordPress migration script
* * *
I'm releasing the PHP script I wrote to migrate my b2 blog engine installation (version 0.6) to WordPress (version 2.0.2) in hopes that it might be useful to any other bloggers who are still stuck with their b2 installations for various reasons.
I decided to write my own script to carry out the migration as the latest WordPress release doesn't contain one and the only other alternative, apparently, would have been to go through a ridiculous series of upgrades (without any guarantees, as I had heavily hacked my b2 installation.) I wasn't interested in keeping my hacks (in fact, no more hacking -- from now on I can create lovely WordPress plugins if I want to add new functionality) but I did want to keep the list of users, posts, categories and comments.
So, without further ado, here's the b2 to WP migration script (b2towp.zip; 19kb).
INSTRUCTIONS
Important: Make sure you have a backup of your b2 database. I recommend that you carry out this procedure on a development box first to make sure you're happy with the results.
- Use PHPMyAdmin to export your b2 database into an SQL file.
- Install WP 2.0.2
- On the machine you installed WP, use PHPMyAdmin to create a database for your b2 database and inport it from the SQL file you created in Step 1.
- Open the b2towp.php file in an editor and enter the database connection info for both the b2 and WP databases at the head of the file.
- Run the b2towp.php script
That should be it. Remember that this script migrates your users, posts, categories and comments only.
The script is released under CC-GNU GPL.
The B2 to WordPress migration script article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.
Subscribe to my blog






Grobbo
Does this also work for HUGE databases? I have a WP blog and a B2 archive that I would like to merge..
May 12th, 2006 at 12:26 pmaral
Hey Grobbo — not sure how you define “HUGE”
The export of my FlashAnt database was 2mb uncompressed. The only issue I can think of as to why it wouldn’t work would be a script timeout or memory issue. You can change the former in the PHP settings and probably add more RAM for the latter
Let me know how you get on good luck!
May 12th, 2006 at 12:57 pmConnie
I have been thinking since forever if I should convert my beloved b2 to Wordpress. I have bookmarked your site for now, and I will most likely give in sooner than later, as the spam is unmanagable with b2. What a shame. Thank you for sharing!
May 17th, 2006 at 10:49 amConnie
Hi Aral,
I have decided to give it a shot, and converting went smoothly, except for the comments. I get this error:
Clearing the comments table… failed.
Inserting comments and updating comment counts in posts table
Warning: Invalid argument supplied for foreach() in /…blah…/convert/b2towp.php on line 385
Which would be // Stats, which again doesnt make much sense to me.
Do you have any suggestions?
Thank you so much in advance!
May 18th, 2006 at 12:14 pmJen
Worked beautifully. Thank you so very much!
June 20th, 2006 at 1:00 amaral
You’re very welcome — great to hear!
June 20th, 2006 at 9:56 amjay
Worked like a fucking charm, I salute you.
July 19th, 2006 at 11:27 amaral
Great to hear, Jay!
July 19th, 2006 at 7:36 pmroycifer
this is fantastic! thank you so much for this! ive been looking high and low for a way to import my old stinky b2 database.
July 28th, 2006 at 8:27 pmJeff
Thanks! Just imported from b2 v0.6pre to Wordpress 2.1.3.
April 25th, 2007 at 1:25 amaral
Hi Jeff, roycifer,
Great news, guys!
April 26th, 2007 at 1:08 pm