Successfully reported this slideshow.
Your SlideShare is downloading. ×

Tricky Migrations

Advertisement

More Related Content

Advertisement
Advertisement

Tricky Migrations

  1. 1. Tricky Migrations Stephanie 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 of Happy 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 database 2. Build $post array 3. 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 On RewriteBase / 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

Editor's Notes

  • \n
  • \n
  • \n
  • \n
  • I&amp;#x2019;m not going to talk much about the HTML import plugin because I&amp;#x2019;d like to get to some other things today, but you can come find me tonight if you want to know whether it&amp;#x2019;ll work in your situation.\n
  • \n
  • \n
  • \n
  • \n
  • Some importers ask you to upload a file. Others ask for credentials so they can fetch data from an external API. This one asks for database connection info. \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • The older Joomla and Drupal import scripts haven&amp;#x2019;t been updated to work with WordPress 3, so you&amp;#x2019;ll need to grab an older version from the release archive, do your import, then upgrade.\n
  • \n
  • \n
  • These are the three main parts of any import script. You might also have functions to fetch authors, comments, and anything else you need to pull out of your old database. The dispatch() function displays greet() and then moves on to import(), which calls all the other functions in turn. \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

×