I often hear that this is “Too Hard!”, so I’ll reveal what I’ve done so far. This is my cheat-sheet being used to migrate single sub-directory WordPress installations into a sub-direcotry configured WordPress Multi-site installation (http://codex.wordpress.org/Create_A_Network). I am too busy and lazy at this point to roll into a nice tight script, but if someone else does I’d be happy to know about it.
Pay close attention to everything in between the “##…##.” That’s stuff you’ll want to replace with your personal issue. Please remember this is to illustrate a multisite move. It’s not elegant, nor is it a proper migration. It just gets the job done. You get no warranty or promises. Use at your own risk.
I currently have to do site reviews anyway for the sites I am migrating, so I haven’t bothered with writing a script yet. I’ll probably start on one when I get time.
Make notes about plugins and settings that might be outside of the standard WordPress database. This doesn't cover moving themes and plugins. This is just about the data.
Get Old site tables by some SQL data dump into a file:
wp_commentmeta
wp_comments
wp_links
wp_options
wp_postmeta
wp_posts
wp_terms
wp_term_relationships
wp_term_taxonomy
Do a replace for the table names in the DB file using an editor or favorite find replace tool. Be aware if your WordPress install is not using a standard database prefix.
`wp_
Replace with
`wp_##mutlisite-number##_
Create a new site for the WordPress Multisite install. Note the new site number and new database tables. You want to replace the database tables for your new wp_##mutlisite-number##_ database tables with the ones rescued from your old site.
-- Run the SQL statements --
/* Fix images */
UPDATE wp_##mutlisite-number##_posts SET post_content = replace(post_content, '##http://old-adress.com/wp-install##/wp-content/uploads/', '##http://new-adress.com/wp-install##/files/');
UPDATE wp_##mutlisite-number##_posts SET guid = replace(guid, '##http://old-adress.com/wp-install##/wp-content/uploads/','##http://new-adress.com/wp-install##/files/');
/* Fix options */
update wp_##mutlisite-number##_options set option_value= replace(option_value,'##http://old-adress.com/wp-install##','##http://new-adress.com/wp-install##');
update wp_##mutlisite-number##_options set option_name= replace(option_name,'wp_user_roles','wp_##mutlisite-number##_user_roles');
/* Fix posts / post-meta*/
UPDATE wp_##mutlisite-number##_posts SET guid = replace(guid, '##http://old-adress.com/wp-install##','##http://new-adress.com/wp-install##');
UPDATE wp_##mutlisite-number##_posts SET post_content = replace(post_content, '##http://old-adress.com/wp-install##', '##http://new-adress.com/wp-install##');
/* Fix file directories */
UPDATE wp_##mutlisite-number##_postmeta SET meta_value = replace(meta_value, '##/old-site-directory/wp-install##/wp-content/uploads/', '##/new-site-directory/wp-install##/wp-content/blogs.dir/##mutlisite-number##/files/');
/* Second Pass */
UPDATE wp_##mutlisite-number##_posts SET guid = replace(guid, '##http://old-adress.com/wp-install##','##http://new-adress.com/wp-install##');
UPDATE wp_##mutlisite-number##_posts SET post_content = replace(post_content, '##http://old-adress.com/wp-install##', '##http://new-adress.com/wp-install##');
/* Fix authors */
update wp_##mutlisite-number##_posts set post_author=1 where post_author<>1;
--- Move Files ---
rsync -avz --delete -e ##/old-site-directory/wp-install##/wp-content/uploads/ ##/new-site-directory/wp-install##/wp-content/blogs.dir/##mutlisite-number##/files/
Leave a Reply