SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
MIGRATING DATA TO DRUPAL 8
Jonathan Araña Cruz
#DrupalCampES2017.drupalcamp.es
about:me
Jonathan Araña Cruz / jonhattan
● +10 years Drupal
● +10 years sysadmin
● Drush maintainer. Other contribs
● Infrastructure as code
● Indentation, syntax highlight addict
Topics
● Migrate & Drupal 8
● Automagic migrations
○ Limitations
● Custom migrations
○ Anatomy of migrations
○ Development workflow
○ Solving hard problems
● Migrating large volumes of data
● Tips & Tricks
Well known solution in contrib (D6, D7)
Drastically changed although
philosophically the same
Migrate contents and configuration
settings
New upgrade path for major version
upgrades (D6,7->D8)
Migrate & Drupal 8
Automagic migrations
● Drupal-to-Drupal
● Wordpress-to-Drupal
● Other sources
Drupal 5, 6 or 7 to Drupal 8
● Install a fresh Drupal 8
● Download and enable Drupal 8 version of your modules
● Enable core modules: Migrate Drupal UI, Migrate Drupal, Migrate
● Visit /upgrade
(Drupal 5 requires Drupal 5 migration (migrate_drupal_d5) module --only supports terms, users and nodes)
Automagic migrations »
Via web
Automagic migrations » Drupal 5, 6 or 7 to Drupal 8
With Drush
drush dl migrate_upgrade
drush en migrate, migrate_drupal, migrate_upgrade
drush migrate-upgrade 
--legacy-db-url=mysql://user:pass@12.34.56.78/d6db 
--legacy-root=http://myd6site.com
● Provided by Migrate Upgrade (migrate_upgrade)
Automagic migrations » Drupal 5, 6 or 7 to Drupal 8
Limitations
● Preserves auto-incremental ids
● Fresh install. One shot.
○ Overwrites existing config
○ No rollbacks
○ No incremental migrations
● 1-1 Migration (attempt)
○ Source structure is literally replicated
● Many modules not covered (imce , ubercart/commerce, ...)
Automagic migrations » Drupal 5, 6 or 7 to Drupal 8
Wordpress to Drupal 8
Two modules available:
● Wordpress Migrate (wordpress_migrate)
○ Migrates WordPress blog exports (WXR format)
○ Posts, pages, comments, attachments, tags and categories
● WP Migrate (wp_migrate)
○ SQL: comments, posts, terms, users, vocabularies
○ Half baked
Automagic migrations »
From other sources to Drupal 8
● SQL, json, xml, csv, excel, …
● No automation
● Helper module Migrate UI (migrate_ui) - outdated with Drupal 8.3.x
Automagic migrations »
Custom migrations
Why?
● Limitations of automagic migrations:
○ One-shot
○ 1-1 migration
○ Unsupported modules
● Incremental migrations, updates, rollbacks
● Opportunities:
○ New site structure
○ Transformation of contents
○ Migrate from diverse sources
○ ...
Custom migrations »
How to
● Migrations are config
● Quickstart: pick & tweak automagic migrations
● Migrate Plus (migrate_plus) provides config entities, hooks, events...
● Put your migrations in a module:
○ mymodule/config/install/migrate_plus.migration.articles.yml
Custom migrations »
drush migrate-upgrade 
--legacy-db-url=mysql://user:pass@12.34.56.78/d6db 
--legacy-root=http://myd6site.com 
--configure-only
Anatomy of migrations (I)
● A migration config consists of:
○ ID, label,...
○ Migration source
○ Migration destination
○ Fields mapping / process
■ Describes, property-by-property, how the destination is to be
constructed from the source data
Custom migrations »
Anatomy of migrations (II)
id: enredate_teachers__user
label: 'enredate.org teachers - user entity'
migration_group: enredate
migration_dependencies: { }
source:
plugin: csv
path: 'private://migrate/sources/crm-teachers.csv'
header_row_count: 1
delimiter: ';'
column_names:
- {Nombre: 'Nombre'}
- {Email: 'Email'}
- {CodWebEnredate: CodWebEnredate}
- {UserNameEnredate: UserNameEnredate}
- {PassEnredate: PassEnredate}
keys: ['CodWebEnredate']
Custom migrations »
Anatomy of migrations (II)
destination:
plugin: 'entity:user'
md5_passwords: true
process:
name: UserNameEnredate
pass: PassEnredate
mail: Email
status:
plugin: default_value
default_value: 1
roles: roles
Custom migrations »
Source plugins (I)
● Core modules provide source plugins for Drupal 6 and 7 elements
○ d6_node, d7_node, user, file, menu, block, ...
● Contrib:
○ Migrate Plus (migrate_plus) - url source and parsers for xml, json, soap
○ Migrate Source CSV (migrate_source_csv)
○ Migrate Google Sheets (migrate_google_sheets)
○ Commerce Migrate (commerce_migrate) - ubercart and commerce sources
Custom migrations » Anatomy of migrations »
Source plugins (II)
● @MigrateSource annotation
● Plugin/migrate/source namespace
● Some core interfaces and base classes:
○ MigrateSourceInterface
○ Node < FieldableEntity < DrupalSqlBase < SqlBase < SourcePluginBase
Custom migrations » Anatomy of migrations »
Destination plugins (I)
Custom migrations » Anatomy of migrations »
● Core modules provide destination plugins for Drupal 8
○ entity:user, entity:node, url_alias…
● Contrib modules provide their destinations as needed
○ field_group, entity_reference_revisions(paragraphs), externalauth, redirect...
● @MigrateDestination annotation
● Plugin/migrate/destination namespace
● Some core interfaces and base classes:
○ MigrateDestinationInterface
○ EntityUser < Entity < DestinationBase
Destination plugins (II)
Custom migrations » Anatomy of migrations »
Process plugins
● Core provides a bunch of plugins:
○ get, callback, concat, default_value, iterator, machine_name,
migration_lookup, skip_on_empty, skip_row_if_not_set, static_map,
substr,...
● Contrib modules provide their process plugins as needed: geofield,
migrate_process_map...
Custom migrations » Anatomy of migrations »
Examples (I)
get default_value static_map
langcode:
plugin: static_map
map:
_esp: es
_cat: ca
_eus: eu
_gal: gl
source: language
mail: Email
mail:
plugin: get
source: Email
init_mail: ‘@mail’
status:
plugin: default_value
default_value: 1
Custom migrations » Anatomy of migrations » Process plugins
Examples (II)
callback migration_lookup skip_on_empty
field_related/target_id:
- plugin: skip_on_empty
source: relacionados
- plugin: migration
migration:
- abo__news
- abo__videos
name:
plugin: callback
callable: trim
source: UserNameEnredate
field_related/target_id:
plugin: migration
migration:
- abo__news
- abo__videos
source: relacionados
Custom migrations » Anatomy of migrations » Process plugins
Pipeline
Custom migrations » Anatomy of migrations » Process plugins
process:
foo:
- plugin: concat
delimiter: '_'
source:
- source1
- source2
- plugin: callback
callable: striptags
- plugin: callback
callable: trim
- plugin: skip_on_empty
- plugin: machine_name
Development workflow
● Code - Execute (import, update) - Debug - Rollback. Cleanup
● You want a runner to execute migrations:
○ Migrate Tools (migrate_tools) - Drush commands & UI
○ Migrate Run (migrate_run) - lightweight fork of Migrate Tools
○ Migrate manifest (migrate_manifest)
Custom migrations »
Debugging
● Migrate Devel (migrate_devel) - extends Migrate Tools
● Drush Entity (drush_entity) - Inspect entities
● Migrate messages and maps
● var_dump() Breakpoints:
○ DrupalmigrateMigrateExecutable::processRow
○ DrupalmigratePluginmigratedestinationEntityContent::import
● Dummy fields
Custom migrations » Lifecycle
dummy:
plugin: callback
callable: drush_print_r
source: source_field
Solving hard problems
● Auxiliary and compound migrations
● Massaging the body
○ Cleanup
○ Convert tokens
○ Get rid of <img>
● Preparation of files and videos
● Redirections in HAProxy
Custom migrations »
Migrating largevolumes of data
What we mean by «large»
● 150k files
● 20k videos
● 60k nodes
● 8k terms
● 30k users
● 1M comments
Large migrations can take hours to run. Days to review.
~9 hours in our best effort
Migrating large volumes of data »
Migrating on steroids
● PHP 7.x & Redis
● MySQL datadir and tmpdir on ramdisk
● MySQL indexes
● Run large migrations in chunks
● Parallelized migrations
● Lightweight database. Drush Shrinkdb (drush_shrinkdb)
● Previous download
Migrating large volumes of data »
Tips & Tricks
First one:
“before [...] you need to stop and
install your brain”
@hernanibf
“My site is slow”
Drupalcamp Spain ‘12
Tips & Tricks
● Ponder. Not everything deserves being migrated automatically
● Prioritize. Not all data have the same value
● Automate & measure. Identify regressions and opportunities to improve
● Use KPIs to measure the quality of the migration
● Test the most important urls
Tips & Tricks
● Order matters
● Ensure consistent source database state
● Use a MySQL read only user to connect the sources
● Don’t do it in production. Prevent performance impact or data loss/corruption
● Test run in a production-like environment. Avoid surprises the M-day
Migrating data to Drupal 8

Weitere ähnliche Inhalte

Was ist angesagt?

Large volume data analysis on the Typesafe Reactive Platform
Large volume data analysis on the Typesafe Reactive PlatformLarge volume data analysis on the Typesafe Reactive Platform
Large volume data analysis on the Typesafe Reactive PlatformMartin Zapletal
 
Geospatial web services using little-known GDAL features and modern Perl midd...
Geospatial web services using little-known GDAL features and modern Perl midd...Geospatial web services using little-known GDAL features and modern Perl midd...
Geospatial web services using little-known GDAL features and modern Perl midd...Ari Jolma
 
MySQL Cluster Schema management (2014)
MySQL Cluster Schema management (2014)MySQL Cluster Schema management (2014)
MySQL Cluster Schema management (2014)Frazer Clement
 
Open stack @ iiit hyderabad
Open stack @ iiit hyderabad Open stack @ iiit hyderabad
Open stack @ iiit hyderabad openstackindia
 
State of GeoServer 2.13
State of GeoServer 2.13State of GeoServer 2.13
State of GeoServer 2.13Jody Garnett
 
CFS: Cassandra backed storage for Hadoop
CFS: Cassandra backed storage for HadoopCFS: Cassandra backed storage for Hadoop
CFS: Cassandra backed storage for Hadoopnickmbailey
 
FITC presents: Mobile & offline data synchronization in Angular JS
FITC presents: Mobile & offline data synchronization in Angular JSFITC presents: Mobile & offline data synchronization in Angular JS
FITC presents: Mobile & offline data synchronization in Angular JSFITC
 
Nko workshop - node js & nosql
Nko workshop - node js & nosqlNko workshop - node js & nosql
Nko workshop - node js & nosqlSimon Su
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013Andy Bunce
 
GeoServer The Open Source Solution for the interoperable management of geos...
GeoServer The Open Source Solution  for the interoperable management  of geos...GeoServer The Open Source Solution  for the interoperable management  of geos...
GeoServer The Open Source Solution for the interoperable management of geos...GeoSolutions
 
GeoServer an introduction for beginners
GeoServer an introduction for beginnersGeoServer an introduction for beginners
GeoServer an introduction for beginnersGeoSolutions
 
An Introduction to Apache Cassandra
An Introduction to Apache CassandraAn Introduction to Apache Cassandra
An Introduction to Apache CassandraSaeid Zebardast
 

Was ist angesagt? (20)

Large volume data analysis on the Typesafe Reactive Platform
Large volume data analysis on the Typesafe Reactive PlatformLarge volume data analysis on the Typesafe Reactive Platform
Large volume data analysis on the Typesafe Reactive Platform
 
Geospatial web services using little-known GDAL features and modern Perl midd...
Geospatial web services using little-known GDAL features and modern Perl midd...Geospatial web services using little-known GDAL features and modern Perl midd...
Geospatial web services using little-known GDAL features and modern Perl midd...
 
MySQL Cluster Schema management (2014)
MySQL Cluster Schema management (2014)MySQL Cluster Schema management (2014)
MySQL Cluster Schema management (2014)
 
Open stack @ iiit hyderabad
Open stack @ iiit hyderabad Open stack @ iiit hyderabad
Open stack @ iiit hyderabad
 
Sprint 74
Sprint 74Sprint 74
Sprint 74
 
The Mobility Project
The Mobility ProjectThe Mobility Project
The Mobility Project
 
Docker Workshop
Docker WorkshopDocker Workshop
Docker Workshop
 
State of GeoServer 2.13
State of GeoServer 2.13State of GeoServer 2.13
State of GeoServer 2.13
 
Lokijs
LokijsLokijs
Lokijs
 
CFS: Cassandra backed storage for Hadoop
CFS: Cassandra backed storage for HadoopCFS: Cassandra backed storage for Hadoop
CFS: Cassandra backed storage for Hadoop
 
FITC presents: Mobile & offline data synchronization in Angular JS
FITC presents: Mobile & offline data synchronization in Angular JSFITC presents: Mobile & offline data synchronization in Angular JS
FITC presents: Mobile & offline data synchronization in Angular JS
 
Cork JUG - Drools basics &amp; pitfalls
Cork JUG - Drools basics &amp; pitfallsCork JUG - Drools basics &amp; pitfalls
Cork JUG - Drools basics &amp; pitfalls
 
Sprint 71
Sprint 71Sprint 71
Sprint 71
 
Nko workshop - node js & nosql
Nko workshop - node js & nosqlNko workshop - node js & nosql
Nko workshop - node js & nosql
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013
 
Sprint 70
Sprint 70Sprint 70
Sprint 70
 
GeoServer The Open Source Solution for the interoperable management of geos...
GeoServer The Open Source Solution  for the interoperable management  of geos...GeoServer The Open Source Solution  for the interoperable management  of geos...
GeoServer The Open Source Solution for the interoperable management of geos...
 
GeoServer an introduction for beginners
GeoServer an introduction for beginnersGeoServer an introduction for beginners
GeoServer an introduction for beginners
 
Drools Workshop @JBCNCONF 2016
Drools Workshop @JBCNCONF 2016Drools Workshop @JBCNCONF 2016
Drools Workshop @JBCNCONF 2016
 
An Introduction to Apache Cassandra
An Introduction to Apache CassandraAn Introduction to Apache Cassandra
An Introduction to Apache Cassandra
 

Ähnlich wie Migrating data to Drupal 8

Conference Migrate to Drupal 8 by Leon Cros at Drupal Developer Days 2015 in ...
Conference Migrate to Drupal 8 by Leon Cros at Drupal Developer Days 2015 in ...Conference Migrate to Drupal 8 by Leon Cros at Drupal Developer Days 2015 in ...
Conference Migrate to Drupal 8 by Leon Cros at Drupal Developer Days 2015 in ...Chipway
 
Drupal Migration
Drupal MigrationDrupal Migration
Drupal Migration永对 陈
 
Devoxx : being productive with JHipster
Devoxx : being productive with JHipsterDevoxx : being productive with JHipster
Devoxx : being productive with JHipsterJulien Dubois
 
Drupal migrations in 2018 - presentation at DrupalCon in Nashville
Drupal migrations in 2018 - presentation at DrupalCon in NashvilleDrupal migrations in 2018 - presentation at DrupalCon in Nashville
Drupal migrations in 2018 - presentation at DrupalCon in NashvilleIrina Zaks
 
Drupal Architecture and functionality
Drupal Architecture and functionality Drupal Architecture and functionality
Drupal Architecture and functionality Ann Lam
 
Srijan's Drupal Migration Practice - an Introduction
Srijan's Drupal Migration Practice - an IntroductionSrijan's Drupal Migration Practice - an Introduction
Srijan's Drupal Migration Practice - an IntroductionSrijan Technologies
 
Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and moreAcquia
 
MIGRATION - PAIN OR GAIN?
MIGRATION - PAIN OR GAIN?MIGRATION - PAIN OR GAIN?
MIGRATION - PAIN OR GAIN?DrupalCamp Kyiv
 
Drupalcon 2021 - Nuxt.js for drupal developers
Drupalcon 2021 - Nuxt.js for drupal developersDrupalcon 2021 - Nuxt.js for drupal developers
Drupalcon 2021 - Nuxt.js for drupal developersnuppla
 
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016Paul McKibben
 
Scaling up and accelerating Drupal 8 with NoSQL
Scaling up and accelerating Drupal 8 with NoSQLScaling up and accelerating Drupal 8 with NoSQL
Scaling up and accelerating Drupal 8 with NoSQLOSInet
 
How to Migrate Drupal 6 to Drupal 8?
How to Migrate Drupal 6 to Drupal 8?How to Migrate Drupal 6 to Drupal 8?
How to Migrate Drupal 6 to Drupal 8?DrupalGeeks
 
Monitoring your VM's at Scale
Monitoring your VM's at ScaleMonitoring your VM's at Scale
Monitoring your VM's at ScaleKris Buytaert
 
Drupal 6 to Drupal 8 Migration
Drupal 6 to Drupal 8 MigrationDrupal 6 to Drupal 8 Migration
Drupal 6 to Drupal 8 MigrationAmeex Technologies
 

Ähnlich wie Migrating data to Drupal 8 (20)

Migrations
MigrationsMigrations
Migrations
 
Conference Migrate to Drupal 8 by Leon Cros at Drupal Developer Days 2015 in ...
Conference Migrate to Drupal 8 by Leon Cros at Drupal Developer Days 2015 in ...Conference Migrate to Drupal 8 by Leon Cros at Drupal Developer Days 2015 in ...
Conference Migrate to Drupal 8 by Leon Cros at Drupal Developer Days 2015 in ...
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
 
Drupal Migration
Drupal MigrationDrupal Migration
Drupal Migration
 
Devoxx : being productive with JHipster
Devoxx : being productive with JHipsterDevoxx : being productive with JHipster
Devoxx : being productive with JHipster
 
Drupal migrations in 2018 - presentation at DrupalCon in Nashville
Drupal migrations in 2018 - presentation at DrupalCon in NashvilleDrupal migrations in 2018 - presentation at DrupalCon in Nashville
Drupal migrations in 2018 - presentation at DrupalCon in Nashville
 
Drupal Architecture and functionality
Drupal Architecture and functionality Drupal Architecture and functionality
Drupal Architecture and functionality
 
Srijan's Drupal Migration Practice - an Introduction
Srijan's Drupal Migration Practice - an IntroductionSrijan's Drupal Migration Practice - an Introduction
Srijan's Drupal Migration Practice - an Introduction
 
Migration
MigrationMigration
Migration
 
Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and more
 
MIGRATION - PAIN OR GAIN?
MIGRATION - PAIN OR GAIN?MIGRATION - PAIN OR GAIN?
MIGRATION - PAIN OR GAIN?
 
Migration to drupal 8.
Migration to drupal 8.Migration to drupal 8.
Migration to drupal 8.
 
Drupalcon 2021 - Nuxt.js for drupal developers
Drupalcon 2021 - Nuxt.js for drupal developersDrupalcon 2021 - Nuxt.js for drupal developers
Drupalcon 2021 - Nuxt.js for drupal developers
 
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
 
Scaling up and accelerating Drupal 8 with NoSQL
Scaling up and accelerating Drupal 8 with NoSQLScaling up and accelerating Drupal 8 with NoSQL
Scaling up and accelerating Drupal 8 with NoSQL
 
Drupal Flyover, CMS Expo
Drupal Flyover, CMS ExpoDrupal Flyover, CMS Expo
Drupal Flyover, CMS Expo
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
 
How to Migrate Drupal 6 to Drupal 8?
How to Migrate Drupal 6 to Drupal 8?How to Migrate Drupal 6 to Drupal 8?
How to Migrate Drupal 6 to Drupal 8?
 
Monitoring your VM's at Scale
Monitoring your VM's at ScaleMonitoring your VM's at Scale
Monitoring your VM's at Scale
 
Drupal 6 to Drupal 8 Migration
Drupal 6 to Drupal 8 MigrationDrupal 6 to Drupal 8 Migration
Drupal 6 to Drupal 8 Migration
 

Kürzlich hochgeladen

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 

Kürzlich hochgeladen (20)

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 

Migrating data to Drupal 8

  • 1. MIGRATING DATA TO DRUPAL 8 Jonathan Araña Cruz #DrupalCampES2017.drupalcamp.es
  • 2. about:me Jonathan Araña Cruz / jonhattan ● +10 years Drupal ● +10 years sysadmin ● Drush maintainer. Other contribs ● Infrastructure as code ● Indentation, syntax highlight addict
  • 3. Topics ● Migrate & Drupal 8 ● Automagic migrations ○ Limitations ● Custom migrations ○ Anatomy of migrations ○ Development workflow ○ Solving hard problems ● Migrating large volumes of data ● Tips & Tricks
  • 4. Well known solution in contrib (D6, D7) Drastically changed although philosophically the same Migrate contents and configuration settings New upgrade path for major version upgrades (D6,7->D8) Migrate & Drupal 8
  • 5. Automagic migrations ● Drupal-to-Drupal ● Wordpress-to-Drupal ● Other sources
  • 6. Drupal 5, 6 or 7 to Drupal 8 ● Install a fresh Drupal 8 ● Download and enable Drupal 8 version of your modules ● Enable core modules: Migrate Drupal UI, Migrate Drupal, Migrate ● Visit /upgrade (Drupal 5 requires Drupal 5 migration (migrate_drupal_d5) module --only supports terms, users and nodes) Automagic migrations »
  • 7. Via web Automagic migrations » Drupal 5, 6 or 7 to Drupal 8
  • 8. With Drush drush dl migrate_upgrade drush en migrate, migrate_drupal, migrate_upgrade drush migrate-upgrade --legacy-db-url=mysql://user:pass@12.34.56.78/d6db --legacy-root=http://myd6site.com ● Provided by Migrate Upgrade (migrate_upgrade) Automagic migrations » Drupal 5, 6 or 7 to Drupal 8
  • 9. Limitations ● Preserves auto-incremental ids ● Fresh install. One shot. ○ Overwrites existing config ○ No rollbacks ○ No incremental migrations ● 1-1 Migration (attempt) ○ Source structure is literally replicated ● Many modules not covered (imce , ubercart/commerce, ...) Automagic migrations » Drupal 5, 6 or 7 to Drupal 8
  • 10. Wordpress to Drupal 8 Two modules available: ● Wordpress Migrate (wordpress_migrate) ○ Migrates WordPress blog exports (WXR format) ○ Posts, pages, comments, attachments, tags and categories ● WP Migrate (wp_migrate) ○ SQL: comments, posts, terms, users, vocabularies ○ Half baked Automagic migrations »
  • 11. From other sources to Drupal 8 ● SQL, json, xml, csv, excel, … ● No automation ● Helper module Migrate UI (migrate_ui) - outdated with Drupal 8.3.x Automagic migrations »
  • 13. Why? ● Limitations of automagic migrations: ○ One-shot ○ 1-1 migration ○ Unsupported modules ● Incremental migrations, updates, rollbacks ● Opportunities: ○ New site structure ○ Transformation of contents ○ Migrate from diverse sources ○ ... Custom migrations »
  • 14. How to ● Migrations are config ● Quickstart: pick & tweak automagic migrations ● Migrate Plus (migrate_plus) provides config entities, hooks, events... ● Put your migrations in a module: ○ mymodule/config/install/migrate_plus.migration.articles.yml Custom migrations » drush migrate-upgrade --legacy-db-url=mysql://user:pass@12.34.56.78/d6db --legacy-root=http://myd6site.com --configure-only
  • 15. Anatomy of migrations (I) ● A migration config consists of: ○ ID, label,... ○ Migration source ○ Migration destination ○ Fields mapping / process ■ Describes, property-by-property, how the destination is to be constructed from the source data Custom migrations »
  • 16. Anatomy of migrations (II) id: enredate_teachers__user label: 'enredate.org teachers - user entity' migration_group: enredate migration_dependencies: { } source: plugin: csv path: 'private://migrate/sources/crm-teachers.csv' header_row_count: 1 delimiter: ';' column_names: - {Nombre: 'Nombre'} - {Email: 'Email'} - {CodWebEnredate: CodWebEnredate} - {UserNameEnredate: UserNameEnredate} - {PassEnredate: PassEnredate} keys: ['CodWebEnredate'] Custom migrations »
  • 17. Anatomy of migrations (II) destination: plugin: 'entity:user' md5_passwords: true process: name: UserNameEnredate pass: PassEnredate mail: Email status: plugin: default_value default_value: 1 roles: roles Custom migrations »
  • 18. Source plugins (I) ● Core modules provide source plugins for Drupal 6 and 7 elements ○ d6_node, d7_node, user, file, menu, block, ... ● Contrib: ○ Migrate Plus (migrate_plus) - url source and parsers for xml, json, soap ○ Migrate Source CSV (migrate_source_csv) ○ Migrate Google Sheets (migrate_google_sheets) ○ Commerce Migrate (commerce_migrate) - ubercart and commerce sources Custom migrations » Anatomy of migrations »
  • 19. Source plugins (II) ● @MigrateSource annotation ● Plugin/migrate/source namespace ● Some core interfaces and base classes: ○ MigrateSourceInterface ○ Node < FieldableEntity < DrupalSqlBase < SqlBase < SourcePluginBase Custom migrations » Anatomy of migrations »
  • 20. Destination plugins (I) Custom migrations » Anatomy of migrations » ● Core modules provide destination plugins for Drupal 8 ○ entity:user, entity:node, url_alias… ● Contrib modules provide their destinations as needed ○ field_group, entity_reference_revisions(paragraphs), externalauth, redirect...
  • 21. ● @MigrateDestination annotation ● Plugin/migrate/destination namespace ● Some core interfaces and base classes: ○ MigrateDestinationInterface ○ EntityUser < Entity < DestinationBase Destination plugins (II) Custom migrations » Anatomy of migrations »
  • 22. Process plugins ● Core provides a bunch of plugins: ○ get, callback, concat, default_value, iterator, machine_name, migration_lookup, skip_on_empty, skip_row_if_not_set, static_map, substr,... ● Contrib modules provide their process plugins as needed: geofield, migrate_process_map... Custom migrations » Anatomy of migrations »
  • 23. Examples (I) get default_value static_map langcode: plugin: static_map map: _esp: es _cat: ca _eus: eu _gal: gl source: language mail: Email mail: plugin: get source: Email init_mail: ‘@mail’ status: plugin: default_value default_value: 1 Custom migrations » Anatomy of migrations » Process plugins
  • 24. Examples (II) callback migration_lookup skip_on_empty field_related/target_id: - plugin: skip_on_empty source: relacionados - plugin: migration migration: - abo__news - abo__videos name: plugin: callback callable: trim source: UserNameEnredate field_related/target_id: plugin: migration migration: - abo__news - abo__videos source: relacionados Custom migrations » Anatomy of migrations » Process plugins
  • 25. Pipeline Custom migrations » Anatomy of migrations » Process plugins process: foo: - plugin: concat delimiter: '_' source: - source1 - source2 - plugin: callback callable: striptags - plugin: callback callable: trim - plugin: skip_on_empty - plugin: machine_name
  • 26. Development workflow ● Code - Execute (import, update) - Debug - Rollback. Cleanup ● You want a runner to execute migrations: ○ Migrate Tools (migrate_tools) - Drush commands & UI ○ Migrate Run (migrate_run) - lightweight fork of Migrate Tools ○ Migrate manifest (migrate_manifest) Custom migrations »
  • 27. Debugging ● Migrate Devel (migrate_devel) - extends Migrate Tools ● Drush Entity (drush_entity) - Inspect entities ● Migrate messages and maps ● var_dump() Breakpoints: ○ DrupalmigrateMigrateExecutable::processRow ○ DrupalmigratePluginmigratedestinationEntityContent::import ● Dummy fields Custom migrations » Lifecycle dummy: plugin: callback callable: drush_print_r source: source_field
  • 28. Solving hard problems ● Auxiliary and compound migrations ● Massaging the body ○ Cleanup ○ Convert tokens ○ Get rid of <img> ● Preparation of files and videos ● Redirections in HAProxy Custom migrations »
  • 30. What we mean by «large» ● 150k files ● 20k videos ● 60k nodes ● 8k terms ● 30k users ● 1M comments Large migrations can take hours to run. Days to review. ~9 hours in our best effort Migrating large volumes of data »
  • 31. Migrating on steroids ● PHP 7.x & Redis ● MySQL datadir and tmpdir on ramdisk ● MySQL indexes ● Run large migrations in chunks ● Parallelized migrations ● Lightweight database. Drush Shrinkdb (drush_shrinkdb) ● Previous download Migrating large volumes of data »
  • 32. Tips & Tricks First one: “before [...] you need to stop and install your brain” @hernanibf “My site is slow” Drupalcamp Spain ‘12
  • 33. Tips & Tricks ● Ponder. Not everything deserves being migrated automatically ● Prioritize. Not all data have the same value ● Automate & measure. Identify regressions and opportunities to improve ● Use KPIs to measure the quality of the migration ● Test the most important urls
  • 34. Tips & Tricks ● Order matters ● Ensure consistent source database state ● Use a MySQL read only user to connect the sources ● Don’t do it in production. Prevent performance impact or data loss/corruption ● Test run in a production-like environment. Avoid surprises the M-day