WordPress Migration Utility


This tool supports migration of a WordPress blog to Drupal. It was derived from code by Claudio Bustos < clbustos {at} apsique dot com >.

It supports:

  • Migration of the user database
  • Migration of posts to selectable target node types (story, blog, page, etc.)
  • Migration of post attributes, including draft, closed to comments, static, etc.
  • Migration of post permalinks using the path module. The link format is not explicitly migrated, and must be manually configured in pathauto for continued consistent use
  • Migration of comments

This has been used against WordPress 1.5 and Drupal 4.6.0, to migrate this very site.

To use it:

  1. Extract the archive anywhere, preferrably somewhere underneath your home directory.
  2. Edit wp_migrate/wp_migrate.php. Fill in the details about how to connect to the source WordPress database and the target Drupal database.
  3. Invoke the PHP command-line interpreter on wp_migrate/wp_migrate.php.

Notes:

  • BACK UP YOUR DATA BEFORE USING THIS PROGRAM.
  • For best results, start from a newly created Drupal database.
  • The $bDeleteAll flag can be used to scrub an existing Drupal installation. If it is set, an attempt will be made to destroy all content-related rows in your Drupal database. This includes all nodes, comments, vocabularies, path aliases, and cache and log entries. This should not affect anything else, including administrative settings and your user database. It may fail to clear state that is related to the deleted entries belonging to add-on modules. USE AT YOUR OWN RISK.
AttachmentSize
wp_migrate.tgz13.29 KB

*  »

chanzero (not verified) Says:

hi,

i want to use your migration script, however i am getting an error saying "Failed opening '../adodb/adodb.inc.php' for inclusion"

however when i look in the adodb folder, i do not see such a file -- they all have names like "adodb-" ("adodob-lib.inc.php", "adodob-php4.inc.php", etc)

i appreciate your help!

-j.chan

»

kettaneh (not verified) Says:

cool blog :)

good luck

»

David Angier (not verified) Says:

Works like a charm, flawlessly took over all the content. Now I have to see whether the end-user prefers Drupal to Wordpress for their needs - which I fully expect.

This has saved me from a migration nightmare, thank you.

»

Brannon (not verified) Says:

Can this be used repeatedly or only once?

I have scripts running that update a (hidden) wordpress site and they are perfect for what they do. Migrating to the live drupal site is the hard part.

Can I use this to update the data or only for initial install? That is, will it check for duplicate nodes or just insert regardless?

-- Thanks in advance for your help.

»

Geoff (not verified) Says:

Is there any chance you would add support for a Drupal database table prefix in wp_migrate.php, like you did you for the WP database portion?

Thanks for your time,

Geoff

»

SneakerElph (not verified) Says:

Conect?ndose a WP por contenidos (mysql): SELECT id, user_login,user_pass,user_email,user_url,user_level FROM wp_users (mysql): SELECT ID,post_date,post_title,post_category, post_content,post_excerpt,post_name,post_author,post_status,comment_status FROM wp_posts ORDER BY post_date (mysql): SELECT cat_id,cat_name,category_nicename,category_description,category_parent from wp_categories (mysql): SELECT post_id,category_id FROM wp_post2cat (mysql): SELECT * from wp_comments Duplicate entry '' for key 2

thats what i get, and only two of my posts for wordpress are carried over. can anyone help?

»

Anonymous (not verified) Says:

* from wp_comments Duplicate entry ” for key 2

I'm getting this too..

»

Rob Cottingham (not verified) Says:

...at which point the script starts importing posts as comments. I've blogged the details at my site.

»

Charo (not verified) Says:

I'm able to connect to the database, but I keep getting this error after it selects the comments from wordpress:
Fatal error: Call to a member function execute() on a non-object in C:\Program Files\xampp\htdocs\drupal\engine.php on line 64
Any ideas? I already placed the adodb folder in the same location as the wp_migrate.php script but it still doesn't work.

»

Charo (not verified) Says:

I was finally able to make my script run. It didn't want to run on my local host but it worked perfectly on the target host. :)

to Brannon
I was able to use the same script thrice, porting three wp databases into one drupal database. (I wanted my three blogs to be accessed on just one drupal site.) It worked great! When doing this, (in wp_migrate.php) the first time you run it, set $bDeleteAll = true to delete existing entries in the target Drupal database. Set it to false for the succeeding databases after that. You might want to set $bPermalinkAlias = false as well if you have trouble importing the permalinks.

to Geoff
I was able to successfully import my wp databases to a drupal database that has a prefix. I just need to clean up my code and resubmit it in case anyone still wants to use the conversion into a prefixed Drupal database.

One last thing, for those who are using this script -- If you find yourself not able to post new items in drupal after using this script, update the entries in the SEQUENCES table. :)

Good luck everybody!

»

Jukka-Pekka Keisala (not verified) Says:

When I am running the script I am getting
Column 'uid' cannot be null.
This error comes out on line 245 echo $db_dr->ErrorMsg();
Any ideas?

»

hpn (not verified) Says:

Maybe you're trying to upgrade from the latest schema of wordpress (They've now moved "userlevel" field to a new table called "usermeta").

»

Mr_Cynical (not verified) Says:

It looks very likely that this will save my blog - my Wordpress install has decided that it doesn't want to let me login (I KNOW the password is correct because I set it in the database myself using phpmyadmin) - so thanks to this script I can just punch in my db details and get to it. Does it generate htaccess redirects or have I found something to spend my weekend doing :(

»

Stephen (not verified) Says:

I get this same error. It looks like I am almost succesful, but it chokes on the wp_comments import.

I'm using WP 1.5.2 and Drupal 4.6.5.

Anyone got a hint for me please?

These are the last details I see.

I thank anyone for help. I might receive.
"Conect?ndose a WP por contenidos (mysql): SELECT id, user_login,user_pass,user_email,user_url,user_level FROM wp_users (mysql): SELECT ID,post_date,post_title,post_category, post_content,post_excerpt,post_name,post_author,post_status,comment_status FROM wp_posts ORDER BY post_date (mysql): SELECT cat_id,cat_name,category_nicename,category_description,category_parent from wp_categories (mysql): SELECT post_id,category_id FROM wp_post2cat (mysql): SELECT * from wp_comments Column 'uid' cannot be null"

»

Steve (not verified) Says:

I found this page extremely helpful for the issues outlned above: http://drupal.org/node/10900

Scroll down, and it explains how to get rid of that pesky error (the "Conect?ndose a WP por contenidos" one) - basically, just set $bPermalinkAlias in wp_migrate.php to 'false'. Hope this works for everyone else.

After this, works like a charm!

Thanks for saving me many, many hours with this script.

»

David Russell (not verified) Says:

Does this include the automatic htaccess writing that wp_goto_dr has? I really don't want to have to write almost 400 redirect codes myself :(

»

tyme (not verified) Says:

I'm trying to use your script but I'm getting an accessed denied. Apparently it is parsing the '_' in my username that I've set as a '•' - I can't avoid having the '_'. any ideae what might be wrong?

»

gravatt (not verified) Says:

When I extract the wp_migrate.tgz file and unzip it, I only have one file within, wp_migrate. and i am also prompted to give this file an extension. So I type php before I can extract. When I finally extract, I don't see any of the other files referenced. What is wrong?

Thanks

»

Spaz (not verified) Says:

It sounds like you're looking at the directory itself. Change into that dir, and run the script.

»

Rob Cottingham (not verified) Says:

Congrats - this script remains the solution to beat for converting to Drupal from WordPress. Is development continuing on it? I'm especially interested given the recent upgrade to WordPress and the impending 4.7 version of Drupal.

»

Rick Vugteveen (not verified) Says:

Hi there,

I tried to use this to migrate to a fresh install of Drupal 4.7 RC but the script gave me errors. Any plans to update? I'm sure that many people have appreciated this script in the past. Hopefully I can do so in the future!

Rick
PS - to help you, here is the error that I get when I run wp_migrate.php:

Conect?ndose a WP por contenidos
(mysql): SELECT id, user_login,user_pass,user_email,user_url,user_level FROM wp_users
(mysql): SELECT ID,post_date,post_title,post_category, post_content,post_excerpt,post_name,post_author,post_status,comment_status FROM wp_posts ORDER BY post_date
(mysql): SELECT cat_id,cat_name,category_nicename,category_description,category_parent from wp_categories
(mysql): SELECT post_id,category_id FROM wp_post2cat
(mysql): SELECT * from wp_comments
Unknown column 'teaser' in 'field list'

»

Rick Vugteveen (not verified) Says:

As per some advice on Drupal.org, I am now using 4.6 for the import and I will then upgrade Drupal to 4.7.

However, I am still having issues with the transfer, which I am detailing here. I would appreciate any help that I can get at this moment! Take care, Rick

»

Subir Ghosh (not verified) Says:

Can the post meta be imported too. For instance, all my items have two custim fields which are stored in the posts2meta table. Can these be imported correctly?

»

Quadszilla (not verified) Says:

I´m thinking of using this script but I´m currently using:

/%year%/%monthnum%/%day%/%postname%/

for my permalinks. How will this interact with the .htaccess and is there a way to easily keep all of my current url names?

»

felicitas (not verified) Says:

Your site is great free ringtones

»

Anonymous (not verified) Says:

any module that intregate drupal4.6.0 and wordpress(any version)
plz help me

»

xainoo (not verified) Says:

can you please help me by email in migrating from 2.0 to 4.7 because the other tool doesn't work?
thanks
bye

»