SlideShare une entreprise Scribd logo
1  sur  38
Automating Drupal
Migrations
How to go from an Estimated One Week to
Two Minutes Down Time
Dan Harris
Founder of Webdrips.com
Nine years Drupal Experience
Front End
Back End
etc.
Porting Node Hierarchy Module to
Drupal 8
About the Speakers
Heron Ordoñez
Senior Developer at NVIDIA
9 years of Drupal Experience
Newspapers
Magazines
Radio and TV
Note About the Migration Process
Although we’re covering a Drupal 6 to 7
migration in this presentation, most if not all of
these ideas presented here should work for any
Drupal to Drupal migration.
Overview: Initial Plan/Estimates
Initial estimate: one week of downtime
SQL queries would be used to export/import
when coverage was limited with Drupal
Migrate
Only automation provided by Migrate Modules
Existing Drupal 7 Architecture
Overview: Updated Plan
Virtually zero downtime
Complete migration in one business day
Over 99% automated
D7 site to be built during migration from
scratch
About the Drupal 6 Site
Architecturally, was a mess (Frankensite)
Migration provided chance to clean up architecture and
code
Six custom themes (1 custom/5 subthemes)
35 custom modules
151 contributed modules
About the Drupal 6 Site
1000 privileged users
About 400k non-privileged users
25 Content Types, including Webforms
Over 2,500 pages
About the Drupal 7 Site
106 Modules
Bootstrap Primary Theme
One Bootstrap subtheme, Four sub-
subthemes
Six content types only
11 Features provided architecture
Automated Migration Process
Requirements
Migrate modules: migrate, migrate_extras, migrate_d2d,
migrate_webform
Import modules: menu_import, path_redirect_import
Four custom modules
Scripts migration and deployment
Fast server with SSD
Migration Script Overview
Requirements:
Create new Drupal D7 site
Build out site architecture with features
Enable Modules
Migrate D6 to D7
Import items that couldn’t be migrated
This provided for a repeatable/reliable process
Migration Script Highlights
(Review)
Build the site:
drush site-install
Enable features and modules:
drush en feature_name -y
Migrate each entity:
drush mi entity
Custom Migration Modules
1.Disable “edits” to the D6 site
a.Basically re-direct webform pages, admin pages,
and paths like node/add, node/edit, etc.
2.Views (implemented with features) only for
migration status and post-processing
3.Migrate_d2d module
4.CSV-based Migration
Drupal Migrate/D2D/Extras
Handled most of the heavy lifting
Everything except menu links, path redirects, and
slide shows
Extensive drush support
Plenty of methods available to massage data
D2D: simplifies migration code
Migrating Users
Challenges
Nearly 400K unprivileged users
Needed to assign users to organic groups
Based on how webform questions answered
Had to fix user passwords
Fixed by writing directly to the user table inside the
migration
Migrate Users Code
Unprivileged vs. Privileged was a simple query:
class NvidiaPrivilegedUserMigration extends NvidiaUserMigration {
protected function query() {
$query = parent::query();
$query->condition('u.mail', '%nvidia.com', 'LIKE/NOT LIKE');
return $query;
}
}
Migrate Users Code
Fix the password:
public function complete($account, $row) {
parent::complete($account, $row);
$account->pass = $row->pass;
db_update('users')
->fields(array('pass' => $account->pass))
->condition('uid', $account->uid)
->execute();
$this->nvidia_memberships($row);
}
Assign Users to Groups (Review)
public function nvidia_memberships($row) {
$membership_query = Database::getConnection('default', 'd6source')-
>select('webform_submissions', 'ws');
$membership_query->join('webform_submitted_data', 'wd', 'wd.sid =
ws.sid');
$membership_query->fields('wd', array('cid'));
$membership_query->fields('ws', array('nid'));
$membership_query->addExpression('group_concat(data)', 'data');
$membership_query->groupBy('ws.sid');
$membership_query->groupBy('cid');
$membership_query->condition('ws.uid', $row->uid);
$membership_query->condition('ws.nid',
array(1234567,2345678,3456789,4567890,5678901), 'IN');
$membership_id = nvidia_og_membership_associate_user_with_program();
Node Migration Challenges
Body images & links with absolute paths
Empty fields sometimes caused display issues
Had to deal with “interesting” architecture
decisions on the D6 site
Moved larger files to the cloud
Reduced the number of content types
Node Migration Code
Dealing with textarea images:
Needed to use Simple HTML DOM Parser
Code Review
How a Strange Dev. Decision can Affect a
Migration
D6 product page and dB variables table (review) led to the following code
$variable_name = 'nvidia_product_disable_product_image_'.$row->nid;
// drush_print_r($variable_name);
$query = Database::getConnection('default', 'd6source')
->select('variable', 'v')
->fields('v', array('name', 'value'))
->condition('v.name', $variable_name, '=')
->execute()
->fetchAll();
$product_image_disabled = $query[0]->value;
if ($product_image_disabled == 'i:1;') {
$row->field_inline_image = NULL;
}
Remove Empty Textarea Fields
public function prepare($entity, stdClass $row) {
foreach ($row as $key => $value) {
if (!isset($row->$key) || $row->$key === null) {
$entity->$key = NULL;
}
}
}
“Non-Standard” Entity Migrations (Review)
D2D handles well-established Drupal entities
well
nodes, users, taxonomy, etc.
But what if you want to migrate block content
to an entity?
CSV Migration to the rescue
Challenges
Biggest challenge was reducing the migration
time
The original estimate just for migrating users was over
40h
Eventually that time was reduced to ~ 3 hours
We tweaked my.cnf, php.ini, drush.ini
Got a really fast server with Intel Xeon processors,
fast RAM, and a SSD
Challenges
Installation of modules in order
circular dependencies
features that add fields need to be installed before
migration
Relationships between content
Both nodes need to exist before creating a
relationship
“Parent” content that did not exist in original site
Migration timeline
-7days to release: Content freeze
-2days: Automated rebuild, content migration
and editorial approval.
-8h: Registration lockdown and migration start
-2h: Batch processing of content by editors
and final tests
Accelerating migration
Use Drush
Single pass for each item
Migration objects are big and slow
Don’t load an object from DB twice
Multithreading
https://www.deeson.co.uk/labs/multi-processing-part-2-how-make-migrate-move
Add multithreading to a working
migration class
Not very portable
needs a Drush extension
needs to run on the ‘fast’ server
Very effective
Add multithreading to a working
migration class
Sub-class the migration
Make all the sub-migrations use the same
index
Make the sub-migration work on a small
‘chunk’ of the index
Break the migration in parts and send chunks
of it to multiple threads
Add multithreading to a working
migration class
<?php
class NVMultiThread extends NvidiaUnprivilegedUserMigration {
public function __construct($args) {
$args += array(
'source_connection' => NVIDIA_MIGRATE_SOURCE_DATABASE,
'source_version' => 6,
'format_mappings' => array(
'1' => 'filtered_html',
'2' => 'full_html',
'3' => 'plain_text',
'4' => 'full_html',
),
'description' => t('Multithreaded Migration of users from Drupal 6'),
'role_migration' => 'Role',
);
This is
boilerplate
needed by
D2D
Add multithreading to a working
migration class
parent::__construct($args);
$this->limit = empty($args['limit']) ? 100 : $args['limit'];
$this->offset = empty($args['offset']) ? 0 : $args['offset'];
$this->map = new MigrateSQLMap('nvidiaunprivilegeduser',
array(
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'User migration reference',
),
),
MigrateDestinationUser::getKeySchema()
);
}
map/index
table
index definition
Add multithreading to a working
migration class
protected function query() {
$query = parent::query();
$query->range($this->arguments['offset'], $this->arguments['limit']);
return $query;
}
}
Modify original
query to limit the
number of items
to work on
Measuring the improvement
Same server
Restore destination DB from backup after
each run
Same source DB
Both DBs in the same server
MySQL optimizations for concurrency issues
Measuring the improvement
1000 items, 100 per thread
Threads Time Speed
1 71s 845/min
2 60s 1000/min
3 54s 1111/min
Measuring the improvement
10,000 items, 1000 per thread
Threads Time Speed
1 707s 848/min
2 303s 1980/min
3 300s 2000/min
4 291s 2061/min
5 351s 1709/min
Measuring the improvement
50,000 items, 5000 per thread
Threads Time Speed
3 1990s 1507/min
4 1562s 1920/min
5 1303s 2302/min
6 1637s 1832/min
Conclusion
Drop DNS TTL to 1 minute days before
launch
Repeatability is key
Migration is very powerful but can be slow
Automation helps drop downtime close to zero
Conclusion
Ask for help
There’s many ways to use Migration, if one
way is not working drop it and use it
differently
CSV vs direct read from DB
Weird things happen with orphaned fields
Questions?
heronog@gmail.com dan@webdrips.com

Contenu connexe

Tendances

Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Scott Leberknight
 
Hazelcast
HazelcastHazelcast
Hazelcastoztalip
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSuzquiano
 
Cassandra 3.0 advanced preview
Cassandra 3.0 advanced previewCassandra 3.0 advanced preview
Cassandra 3.0 advanced previewPatrick McFadin
 
Cassandra Summit 2013 Keynote
Cassandra Summit 2013 KeynoteCassandra Summit 2013 Keynote
Cassandra Summit 2013 Keynotejbellis
 
Deployment in Oracle SOA Suite and in Oracle BPM Suite
Deployment in Oracle SOA Suite and in Oracle BPM SuiteDeployment in Oracle SOA Suite and in Oracle BPM Suite
Deployment in Oracle SOA Suite and in Oracle BPM SuiteLonneke Dikmans
 
Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2Ralph Schindler
 
Paris Cassandra Meetup - Cassandra for Developers
Paris Cassandra Meetup - Cassandra for DevelopersParis Cassandra Meetup - Cassandra for Developers
Paris Cassandra Meetup - Cassandra for DevelopersMichaël Figuière
 
Geneva JUG - Cassandra for Java Developers
Geneva JUG - Cassandra for Java DevelopersGeneva JUG - Cassandra for Java Developers
Geneva JUG - Cassandra for Java DevelopersMichaël Figuière
 
Andrzej Ludwikowski - Event Sourcing - co może pójść nie tak?
Andrzej Ludwikowski -  Event Sourcing - co może pójść nie tak?Andrzej Ludwikowski -  Event Sourcing - co może pójść nie tak?
Andrzej Ludwikowski - Event Sourcing - co może pójść nie tak?SegFaultConf
 
YaJug - Cassandra for Java Developers
YaJug - Cassandra for Java DevelopersYaJug - Cassandra for Java Developers
YaJug - Cassandra for Java DevelopersMichaël Figuière
 
Oozie Summit 2011
Oozie Summit 2011Oozie Summit 2011
Oozie Summit 2011mislam77
 

Tendances (20)

Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0
 
Hazelcast
HazelcastHazelcast
Hazelcast
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
Cassandra 3.0 advanced preview
Cassandra 3.0 advanced previewCassandra 3.0 advanced preview
Cassandra 3.0 advanced preview
 
ChtiJUG - Cassandra 2.0
ChtiJUG - Cassandra 2.0ChtiJUG - Cassandra 2.0
ChtiJUG - Cassandra 2.0
 
Cassandra Summit 2013 Keynote
Cassandra Summit 2013 KeynoteCassandra Summit 2013 Keynote
Cassandra Summit 2013 Keynote
 
Deployment in Oracle SOA Suite and in Oracle BPM Suite
Deployment in Oracle SOA Suite and in Oracle BPM SuiteDeployment in Oracle SOA Suite and in Oracle BPM Suite
Deployment in Oracle SOA Suite and in Oracle BPM Suite
 
Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2
 
Paris Cassandra Meetup - Cassandra for Developers
Paris Cassandra Meetup - Cassandra for DevelopersParis Cassandra Meetup - Cassandra for Developers
Paris Cassandra Meetup - Cassandra for Developers
 
Geneva JUG - Cassandra for Java Developers
Geneva JUG - Cassandra for Java DevelopersGeneva JUG - Cassandra for Java Developers
Geneva JUG - Cassandra for Java Developers
 
Andrzej Ludwikowski - Event Sourcing - co może pójść nie tak?
Andrzej Ludwikowski -  Event Sourcing - co może pójść nie tak?Andrzej Ludwikowski -  Event Sourcing - co może pójść nie tak?
Andrzej Ludwikowski - Event Sourcing - co może pójść nie tak?
 
Migrate
MigrateMigrate
Migrate
 
Hazelcast
HazelcastHazelcast
Hazelcast
 
Grails 2.0 Update
Grails 2.0 UpdateGrails 2.0 Update
Grails 2.0 Update
 
YaJug - Cassandra for Java Developers
YaJug - Cassandra for Java DevelopersYaJug - Cassandra for Java Developers
YaJug - Cassandra for Java Developers
 
Oozie Summit 2011
Oozie Summit 2011Oozie Summit 2011
Oozie Summit 2011
 
React Internals
React InternalsReact Internals
React Internals
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
Requery overview
Requery overviewRequery overview
Requery overview
 
jQuery Objects
jQuery ObjectsjQuery Objects
jQuery Objects
 

Similaire à Automating Drupal Migrations

Migrating data into Drupal using the migrate module
Migrating data into Drupal using the migrate moduleMigrating data into Drupal using the migrate module
Migrating data into Drupal using the migrate moduleJohan Gant
 
Migrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
Migrating to Drupal 8: How to Migrate Your Content and Minimize the RisksMigrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
Migrating to Drupal 8: How to Migrate Your Content and Minimize the RisksAcquia
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011camp_drupal_ua
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGapAlex S
 
Doing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonDoing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonGábor Hojtsy
 
Taking your site from Drupal 6 to Drupal 7
Taking your site from Drupal 6 to Drupal 7Taking your site from Drupal 6 to Drupal 7
Taking your site from Drupal 6 to Drupal 7Phase2
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaGábor Hojtsy
 
Content Staging in Drupal 8
Content Staging in Drupal 8Content Staging in Drupal 8
Content Staging in Drupal 8Dick Olsson
 
A pain free migraine
A pain free migraineA pain free migraine
A pain free migraineDennis Solis
 
Addressing Scenario
Addressing ScenarioAddressing Scenario
Addressing ScenarioTara Hardin
 
RedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis codeRedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis codeRedis Labs
 
Drupal as a web framework
Drupal as a web frameworkDrupal as a web framework
Drupal as a web frameworkAdam Kalsey
 
Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.Nelson Gomes
 

Similaire à Automating Drupal Migrations (20)

Migrating data into Drupal using the migrate module
Migrating data into Drupal using the migrate moduleMigrating data into Drupal using the migrate module
Migrating data into Drupal using the migrate module
 
Migrating data to drupal 8
Migrating data to drupal 8Migrating data to drupal 8
Migrating data to drupal 8
 
Migrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
Migrating to Drupal 8: How to Migrate Your Content and Minimize the RisksMigrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
Migrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
 
Migrate in Drupal 8
Migrate in Drupal 8Migrate in Drupal 8
Migrate in Drupal 8
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGap
 
Doing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonDoing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon London
 
Taking your site from Drupal 6 to Drupal 7
Taking your site from Drupal 6 to Drupal 7Taking your site from Drupal 6 to Drupal 7
Taking your site from Drupal 6 to Drupal 7
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp Bratislava
 
Migrations
MigrationsMigrations
Migrations
 
Content Staging in Drupal 8
Content Staging in Drupal 8Content Staging in Drupal 8
Content Staging in Drupal 8
 
A pain free migraine
A pain free migraineA pain free migraine
A pain free migraine
 
Addressing Scenario
Addressing ScenarioAddressing Scenario
Addressing Scenario
 
RedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis codeRedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis code
 
Doctrine and NoSQL
Doctrine and NoSQLDoctrine and NoSQL
Doctrine and NoSQL
 
Drupal as a web framework
Drupal as a web frameworkDrupal as a web framework
Drupal as a web framework
 
Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.
 
Migration to drupal 8.
Migration to drupal 8.Migration to drupal 8.
Migration to drupal 8.
 

Plus de littleMAS

Drupal 8 Point 1 & Membership Survey
Drupal 8 Point 1 & Membership SurveyDrupal 8 Point 1 & Membership Survey
Drupal 8 Point 1 & Membership SurveylittleMAS
 
Drupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source AppDrupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source ApplittleMAS
 
Drupal 8 Spinathon
Drupal 8 SpinathonDrupal 8 Spinathon
Drupal 8 SpinathonlittleMAS
 
Drupal 8 Beta on GoDaddy Notes
Drupal 8 Beta on GoDaddy NotesDrupal 8 Beta on GoDaddy Notes
Drupal 8 Beta on GoDaddy NoteslittleMAS
 
DrupalCon LA 2015 Review
DrupalCon LA 2015 ReviewDrupalCon LA 2015 Review
DrupalCon LA 2015 ReviewlittleMAS
 
iOS RESTful Library for Drupal 8
iOS RESTful Library for Drupal 8iOS RESTful Library for Drupal 8
iOS RESTful Library for Drupal 8littleMAS
 
Build Mobile Apps Using PhoneGap and Drupal by Tyler Frankenstein
Build Mobile Apps Using PhoneGap and Drupal by Tyler FrankensteinBuild Mobile Apps Using PhoneGap and Drupal by Tyler Frankenstein
Build Mobile Apps Using PhoneGap and Drupal by Tyler FrankensteinlittleMAS
 
Drupal%2 c mobility and m2serve
Drupal%2 c mobility and m2serveDrupal%2 c mobility and m2serve
Drupal%2 c mobility and m2servelittleMAS
 
Drupal for Mobile
Drupal for MobileDrupal for Mobile
Drupal for MobilelittleMAS
 

Plus de littleMAS (9)

Drupal 8 Point 1 & Membership Survey
Drupal 8 Point 1 & Membership SurveyDrupal 8 Point 1 & Membership Survey
Drupal 8 Point 1 & Membership Survey
 
Drupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source AppDrupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source App
 
Drupal 8 Spinathon
Drupal 8 SpinathonDrupal 8 Spinathon
Drupal 8 Spinathon
 
Drupal 8 Beta on GoDaddy Notes
Drupal 8 Beta on GoDaddy NotesDrupal 8 Beta on GoDaddy Notes
Drupal 8 Beta on GoDaddy Notes
 
DrupalCon LA 2015 Review
DrupalCon LA 2015 ReviewDrupalCon LA 2015 Review
DrupalCon LA 2015 Review
 
iOS RESTful Library for Drupal 8
iOS RESTful Library for Drupal 8iOS RESTful Library for Drupal 8
iOS RESTful Library for Drupal 8
 
Build Mobile Apps Using PhoneGap and Drupal by Tyler Frankenstein
Build Mobile Apps Using PhoneGap and Drupal by Tyler FrankensteinBuild Mobile Apps Using PhoneGap and Drupal by Tyler Frankenstein
Build Mobile Apps Using PhoneGap and Drupal by Tyler Frankenstein
 
Drupal%2 c mobility and m2serve
Drupal%2 c mobility and m2serveDrupal%2 c mobility and m2serve
Drupal%2 c mobility and m2serve
 
Drupal for Mobile
Drupal for MobileDrupal for Mobile
Drupal for Mobile
 

Dernier

GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.soniya singh
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...Escorts Call Girls
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)Delhi Call girls
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...tanu pandey
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663Call Girls Mumbai
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Onlineanilsa9823
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.CarlotaBedoya1
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 

Dernier (20)

GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 

Automating Drupal Migrations

  • 1. Automating Drupal Migrations How to go from an Estimated One Week to Two Minutes Down Time
  • 2. Dan Harris Founder of Webdrips.com Nine years Drupal Experience Front End Back End etc. Porting Node Hierarchy Module to Drupal 8 About the Speakers Heron Ordoñez Senior Developer at NVIDIA 9 years of Drupal Experience Newspapers Magazines Radio and TV
  • 3. Note About the Migration Process Although we’re covering a Drupal 6 to 7 migration in this presentation, most if not all of these ideas presented here should work for any Drupal to Drupal migration.
  • 4. Overview: Initial Plan/Estimates Initial estimate: one week of downtime SQL queries would be used to export/import when coverage was limited with Drupal Migrate Only automation provided by Migrate Modules Existing Drupal 7 Architecture
  • 5. Overview: Updated Plan Virtually zero downtime Complete migration in one business day Over 99% automated D7 site to be built during migration from scratch
  • 6. About the Drupal 6 Site Architecturally, was a mess (Frankensite) Migration provided chance to clean up architecture and code Six custom themes (1 custom/5 subthemes) 35 custom modules 151 contributed modules
  • 7. About the Drupal 6 Site 1000 privileged users About 400k non-privileged users 25 Content Types, including Webforms Over 2,500 pages
  • 8. About the Drupal 7 Site 106 Modules Bootstrap Primary Theme One Bootstrap subtheme, Four sub- subthemes Six content types only 11 Features provided architecture
  • 9. Automated Migration Process Requirements Migrate modules: migrate, migrate_extras, migrate_d2d, migrate_webform Import modules: menu_import, path_redirect_import Four custom modules Scripts migration and deployment Fast server with SSD
  • 10. Migration Script Overview Requirements: Create new Drupal D7 site Build out site architecture with features Enable Modules Migrate D6 to D7 Import items that couldn’t be migrated This provided for a repeatable/reliable process
  • 11. Migration Script Highlights (Review) Build the site: drush site-install Enable features and modules: drush en feature_name -y Migrate each entity: drush mi entity
  • 12. Custom Migration Modules 1.Disable “edits” to the D6 site a.Basically re-direct webform pages, admin pages, and paths like node/add, node/edit, etc. 2.Views (implemented with features) only for migration status and post-processing 3.Migrate_d2d module 4.CSV-based Migration
  • 13. Drupal Migrate/D2D/Extras Handled most of the heavy lifting Everything except menu links, path redirects, and slide shows Extensive drush support Plenty of methods available to massage data D2D: simplifies migration code
  • 14. Migrating Users Challenges Nearly 400K unprivileged users Needed to assign users to organic groups Based on how webform questions answered Had to fix user passwords Fixed by writing directly to the user table inside the migration
  • 15. Migrate Users Code Unprivileged vs. Privileged was a simple query: class NvidiaPrivilegedUserMigration extends NvidiaUserMigration { protected function query() { $query = parent::query(); $query->condition('u.mail', '%nvidia.com', 'LIKE/NOT LIKE'); return $query; } }
  • 16. Migrate Users Code Fix the password: public function complete($account, $row) { parent::complete($account, $row); $account->pass = $row->pass; db_update('users') ->fields(array('pass' => $account->pass)) ->condition('uid', $account->uid) ->execute(); $this->nvidia_memberships($row); }
  • 17. Assign Users to Groups (Review) public function nvidia_memberships($row) { $membership_query = Database::getConnection('default', 'd6source')- >select('webform_submissions', 'ws'); $membership_query->join('webform_submitted_data', 'wd', 'wd.sid = ws.sid'); $membership_query->fields('wd', array('cid')); $membership_query->fields('ws', array('nid')); $membership_query->addExpression('group_concat(data)', 'data'); $membership_query->groupBy('ws.sid'); $membership_query->groupBy('cid'); $membership_query->condition('ws.uid', $row->uid); $membership_query->condition('ws.nid', array(1234567,2345678,3456789,4567890,5678901), 'IN'); $membership_id = nvidia_og_membership_associate_user_with_program();
  • 18. Node Migration Challenges Body images & links with absolute paths Empty fields sometimes caused display issues Had to deal with “interesting” architecture decisions on the D6 site Moved larger files to the cloud Reduced the number of content types
  • 19. Node Migration Code Dealing with textarea images: Needed to use Simple HTML DOM Parser Code Review
  • 20. How a Strange Dev. Decision can Affect a Migration D6 product page and dB variables table (review) led to the following code $variable_name = 'nvidia_product_disable_product_image_'.$row->nid; // drush_print_r($variable_name); $query = Database::getConnection('default', 'd6source') ->select('variable', 'v') ->fields('v', array('name', 'value')) ->condition('v.name', $variable_name, '=') ->execute() ->fetchAll(); $product_image_disabled = $query[0]->value; if ($product_image_disabled == 'i:1;') { $row->field_inline_image = NULL; }
  • 21. Remove Empty Textarea Fields public function prepare($entity, stdClass $row) { foreach ($row as $key => $value) { if (!isset($row->$key) || $row->$key === null) { $entity->$key = NULL; } } }
  • 22. “Non-Standard” Entity Migrations (Review) D2D handles well-established Drupal entities well nodes, users, taxonomy, etc. But what if you want to migrate block content to an entity? CSV Migration to the rescue
  • 23. Challenges Biggest challenge was reducing the migration time The original estimate just for migrating users was over 40h Eventually that time was reduced to ~ 3 hours We tweaked my.cnf, php.ini, drush.ini Got a really fast server with Intel Xeon processors, fast RAM, and a SSD
  • 24. Challenges Installation of modules in order circular dependencies features that add fields need to be installed before migration Relationships between content Both nodes need to exist before creating a relationship “Parent” content that did not exist in original site
  • 25. Migration timeline -7days to release: Content freeze -2days: Automated rebuild, content migration and editorial approval. -8h: Registration lockdown and migration start -2h: Batch processing of content by editors and final tests
  • 26. Accelerating migration Use Drush Single pass for each item Migration objects are big and slow Don’t load an object from DB twice Multithreading https://www.deeson.co.uk/labs/multi-processing-part-2-how-make-migrate-move
  • 27. Add multithreading to a working migration class Not very portable needs a Drush extension needs to run on the ‘fast’ server Very effective
  • 28. Add multithreading to a working migration class Sub-class the migration Make all the sub-migrations use the same index Make the sub-migration work on a small ‘chunk’ of the index Break the migration in parts and send chunks of it to multiple threads
  • 29. Add multithreading to a working migration class <?php class NVMultiThread extends NvidiaUnprivilegedUserMigration { public function __construct($args) { $args += array( 'source_connection' => NVIDIA_MIGRATE_SOURCE_DATABASE, 'source_version' => 6, 'format_mappings' => array( '1' => 'filtered_html', '2' => 'full_html', '3' => 'plain_text', '4' => 'full_html', ), 'description' => t('Multithreaded Migration of users from Drupal 6'), 'role_migration' => 'Role', ); This is boilerplate needed by D2D
  • 30. Add multithreading to a working migration class parent::__construct($args); $this->limit = empty($args['limit']) ? 100 : $args['limit']; $this->offset = empty($args['offset']) ? 0 : $args['offset']; $this->map = new MigrateSQLMap('nvidiaunprivilegeduser', array( 'uid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'User migration reference', ), ), MigrateDestinationUser::getKeySchema() ); } map/index table index definition
  • 31. Add multithreading to a working migration class protected function query() { $query = parent::query(); $query->range($this->arguments['offset'], $this->arguments['limit']); return $query; } } Modify original query to limit the number of items to work on
  • 32. Measuring the improvement Same server Restore destination DB from backup after each run Same source DB Both DBs in the same server MySQL optimizations for concurrency issues
  • 33. Measuring the improvement 1000 items, 100 per thread Threads Time Speed 1 71s 845/min 2 60s 1000/min 3 54s 1111/min
  • 34. Measuring the improvement 10,000 items, 1000 per thread Threads Time Speed 1 707s 848/min 2 303s 1980/min 3 300s 2000/min 4 291s 2061/min 5 351s 1709/min
  • 35. Measuring the improvement 50,000 items, 5000 per thread Threads Time Speed 3 1990s 1507/min 4 1562s 1920/min 5 1303s 2302/min 6 1637s 1832/min
  • 36. Conclusion Drop DNS TTL to 1 minute days before launch Repeatability is key Migration is very powerful but can be slow Automation helps drop downtime close to zero
  • 37. Conclusion Ask for help There’s many ways to use Migration, if one way is not working drop it and use it differently CSV vs direct read from DB Weird things happen with orphaned fields