Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Tricky Migrations

3,659 views

Published on

Importing from unusual sources; migrating single installations into multisite networks.

  • I like to add CSV importer - https://www.smackcoders.com/wp-ultimate-csv-importer-pro.html. An advanced Solution for bulk CSV Import. WP Ultimate CSV Importer is a robust tool designed to help you make your website development easy. Through advanced features like update, schedule, drag & drop mapping, duplicate handling, export and much more, you’ll be able to perfectly create professional eCommerce website.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Tricky Migrations

  1. 1. Tricky MigrationsStephanie Leary sillybean.net @sleary
  2. 2. Who am I?• sillybean.net• @sleary• slideshare.net/ stephanieleary
  3. 3. I’ve imported from...• Blogger • Joomla• Movable Type • Drupal• Textpattern • Twitter• LiveJournal • Gallery2• WordPress.com • Delicious• CSV files • HTML files
  4. 4. HTML Import
  5. 5. Gallery2 Importer
  6. 6. Secrets ofHappy Importing
  7. 7. Preparation• Back up• Prepare to undo• Import on development server • Or turn on maintenance mode• Turn off crossposting plugins• Use absolute URLs for linked files
  8. 8. Plugins• DB Backup http://wordpress.org/extend/plugins/wp-db-backup/• Mass Page Remover http://wordpress.org/extend/plugins/mass-page-remover/• WordPress Reset http://wordpress.org/extend/plugins/wordpress-reset/• Maintenance Mode http://wordpress.org/extend/plugins/maintenance-mode/
  9. 9. WordPress export• Posts, pages, comments, authors• Uploads optional• No settings• No menus in 3.0 (fixed in 3.1)• Category slug issues• Custom post types and taxonomies
  10. 10. Uncommon imports• Twitter http://wordpress.org/extend/plugins/twitter-importer/• Delicious http://wordpress.org/extend/plugins/delicious-xml-importer/• Gallery2 http://wordpress.org/extend/plugins/gallery2-importer/• HTML http://wordpress.org/extend/plugins/import-html-pages/
  11. 11. Uncommon imports• Joomla/Mambo • 1.0 to WP 2.7x: http://tinyurl.com/joom2wp • 1.5 to WP 3.0x: http://wordpress.org/extend/plugins/ joomla-15-importer/• Drupal • 6.x to WP 2.7x: http://tinyurl.com/dru6wp2 • 5.x to WP 2.7x: http://tinyurl.com/dru5wp2• CSV http://wordpress.org/extend/plugins/csv-importer/
  12. 12. Custom imports• Other MySQL-based CMSs http://yoast.com/importing-from-another-mysql-into-wordpress/ http://codex.wordpress.org/Function_Reference/wp_insert_post/1. Fetch data from old database2. Build $post array3. wp_insert_post ( $post );
  13. 13. while($row = mysql_fetch_array($results,MYSQL_ASSOC)) { $post = array(); $post[ post_status ] = draft; $post[ post_author ] = $row[ user ]; $post[ post_date ] = $row[ date ]; $post[ post_title ] = $row[ title ]; $post[ post_content ] = $row[ content ]; wp_insert_post( $post );}
  14. 14. Writing an import plugin• Import class• class Gallery2_Import extends WP_Importer • form: greet() • get posts: get_posts() • clean up & insert: process_posts()
  15. 15. After importing• Search & Replace http://wordpress.org/extend/plugins/search-and-replace/• Redirection http://wordpress.org/extend/plugins/redirection/• Add Linked Images to Gallery http://wordpress.org/extend/plugins/add-linked-images- to-gallery-v01/
  16. 16. Single Install ↓ Network
  17. 17. Second verse...• Back up• Prepare to undo• Migrate on development server
  18. 18. XML or MySQL?• XML pros • MySQL pros • simple • complete • limited • complicated • slug bug • merging users • skipped users • manual edits
  19. 19. Moving databases• export all tables except users, usermeta• change table prefixes• change wp_userroles option name to match new table prefix• change wp_* fields in wp_usermeta table to match prefix
  20. 20. Moving user tables• Export users, usermeta • or specific rows• Manually change IDs• Stab yourself in the eye with a fork• http://sillybean.net/?p=6187
  21. 21. Compromise• Use WordPress export to move content and taxonomies• Have it create or map new users• Move only the wp_options table by hand
  22. 22. Character sets• define(DB_CHARSET, latin1);• Try to convert the old db • work with a copy! • Alter the table http://codesnippets.joyent.com/posts/show/306 • Export Latin1, import UTF-8 http://alexking.org/blog/2008/03/06/mysql-latin1-utf8- conversion
  23. 23. After migrating• Move static files• Change upload file paths http://yoursite.com/wp-content/ http://yoursite.com/files/ • options • posts • theme files
  24. 24. Combining .htaccess<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{HTTP_HOST} ^one.foo.com$ [NC]Redirect /forms.html http://one.foo.com/forms/ [R=301,NC]RewriteCond %{HTTP_HOST} ^two.foo.com$ [NC]Redirect /about.html http://two.foo.com/about/ [R=301,NC]</IfModule>
  25. 25. ?
  26. 26. Thank you. Stephanie Leary sillybean.net @sleary

×