[DRUPAL] How to Migrate content types, taxonomy term and users from Drupal 7 to Drupal 8 using Drush.

In this article, we are describing the simplest content migration from drupal 6 or 7 to drupal 8 using the Drush commands. We are not using any custom module source code for this migration process. For one of our client need to rebuild the drupal 7 site in drupal 8 without any changes. For this case we need all the data from drupal 7 site need to be there in the drupal 8 site. We need to migrate everything including the content types, users, taxonomy etc without any change. If we are planning to migrate a Drupal 7 site to Drupal 8 without any changes to content types, taxonomy and user details, we can easily do with few Drush commands. If we are planning to change the content type field or we are combining any two content types fileds or replacing any content type with new content type we need to migrate with our custom code.

For this migration we need to setup the drupal 7 site database inside a new database. Then move with the drupal 8 basic site setup.  The one main thing we need to consider database level migration is to add the migrating database details inside the drupal 8 settings.php file.

Added the database details of drupal 7 site inside the drupal 8 settings.php file.

$databases['migrate']['default'] = array (

 'database' => 'drupal_7_database_name',
  'username' => 'db_username',
  'password' => 'db_password',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

Download and enable the migrate tool module along with the drupal 8 core migrate modules.

 

drush migrate-status 

will give the migration status there we can get the details of things we can migrate as show below.  We will get the list of migration id with this we can manage the migrations from drupal 7 to drupal 8.

Group               Migration ID                                       Status   Total   Imported   Unprocessed   Last Imported        
 ------------------- -------------------------------------------------- -------- ------- ---------- ------------- --------------------- 
  Default (default)   contact_category                                   Idle     1       0          1                                  
  Default (default)   d6_aggregator_settings                             Idle     0       0          0                                  
  Default (default)   d6_date_formats                                    Idle     0       0          0                                  
  Default (default)   d6_dblog_settings                                  Idle     1       0          1                                  
  Default (default)   d6_entity_reference_translation:comment__comment   Idle     N/A     0          N/A                                
  Default (default)   d6_filter_format                                   Idle     N/A     0          N/A                                
  Default (default)   d6_language_content_menu_settings                  Idle     0       0          0                                  
  Default (default)   d6_language_types                                  Idle     0       0          0                                  
  Default (default)   d6_node_settings                                   Idle     1       0          1                                  
  Default (default)   d6_search_settings                                 Idle     0       0          0                                  
  Default (default)   d6_system_cron                                     Idle     1       0          1                                  
  Default (default)   d6_system_date                                     Idle     1       0          1                                  
  Default (default)   d6_system_file                                     Idle     0       0          0                                  
  Default (default)   d6_system_maintenance_translation                  Idle     N/A     0          N/A                                
  Default (default)   d6_system_performance                              Idle     1       0          1                                  
  Default (default)   d6_system_site_translation                         Idle     N/A     0          N/A                                
  Default (default)   d6_url_alias                                       Idle     305     0          305                                
  Default (default)   d6_user_mail                                       Idle     1       0          1                                  
  Default (default)   d6_user_mail_translation                           Idle     N/A     0          N/A                                
  Default (default)   d6_user_settings                                   Idle     1       0          1                                  
  Default (default)   d6_user_settings_translation                       Idle     N/A     0          N/A                                
  Default (default)   d7_aggregator_settings                             Idle     0       0          0                                  
  Default (default)   d7_color                                           Idle     0       0          0                                  
  Default (default)   d7_dblog_settings                                  Idle     1       0          1                                  
  Default (default)   d7_file_private                                    Idle     0       0          0                                  
  Default (default)   d7_filter_settings                                 Idle     1       0          1                                  
  Default (default)   d7_global_theme_settings                           Idle     1       0          1                                  
  Default (default)   d7_image_settings                                  Idle     0       1          -1            2018-12-12 18:06:12  
  Default (default)   d7_image_styles                                    Idle     10      10         0             2018-12-12 18:06:27  
  Default (default)   d7_language_types                                  Idle     0       0          0                                  
  Default (default)   d7_node_settings                                   Idle     1       0          1                                  
  Default (default)   d7_path_redirect                                   Idle     38      0          38                                 
  Default (default)   d7_search_settings                                 Idle     0       0          0                                  
  Default (default)   d7_system_authorize                                Idle     0       0          0                                  
  Default (default)   d7_system_cron                                     Idle     0       0          0                                  
  Default (default)   d7_system_date                                     Idle     1       0          1                                  
  Default (default)   d7_system_file                                     Idle     1       0          1                                  
  Default (default)   d7_system_mail                                     Idle     1       0          1                                  
  Default (default)   d7_system_performance                              Idle     1       0          1                                  
  Default (default)   d7_theme_settings                                  Idle     3       0          3                                  
  Default (default)   d7_user_flood                                      Idle     1       0          1                                  
  Default (default)   d7_user_mail                                       Idle     1       0          1                                  
  Default (default)   file_settings                                      Idle     0       0          0                                  
  Default (default)   locale_settings                                    Idle     0       0          0                                  
  Default (default)   menu_settings                                      Idle     0       1          -1            2018-12-12 18:34:03  
  Default (default)   search_page                                        Idle     0       0          0                                  
  Default (default)   system_image                                       Idle     1       0          1                                  
  Default (default)   system_image_gd                                    Idle     1       0          1                                  
  Default (default)   system_logging                                     Idle     1       0          1                                  
  Default (default)   system_maintenance                                 Idle     0       0          0                                  
  Default (default)   system_rss                                         Idle     0       0          0                                  
  Default (default)   system_site                                        Idle     1       0          1                                  
  Default (default)   taxonomy_settings                                  Idle     0       0          0                                  
  Default (default)   text_settings                                      Idle     0       0          0                                  
  Default (default)   update_settings                                    Idle     1       0          1                                  
  Default (default)   block_content_type                                 Idle     1       1          0             2018-12-12 18:36:40  
  Default (default)   d6_contact_settings                                Idle     1       0          1                                  
  Default (default)   block_content_body_field                           Idle     1       1          0             2018-12-12 18:36:52  
  Default (default)   d7_contact_settings                                Idle     1       0          1                                  
  Default (default)   d6_custom_block                                    Idle     N/A     0          N/A                                
  Default (default)   d6_user_role                                       Idle     4       0          4                                  
  Default (default)   d6_block                                           Idle     676     0          676                                
  Default (default)   d7_filter_format                                   Idle     5       0          5                                  
  Default (default)   d7_custom_block                                    Idle     102     0          102                                
  Default (default)   d7_user_role                                       Idle     4       4          0             2018-12-12 17:57:43  
  Default (default)   d7_block                                           Idle     676     0          676                                
  Default (default)   block_content_entity_display                       Idle     1       0          1                                  
  Default (default)   block_content_entity_form_display                  Idle     1       0          1                                  
  Default (default)   d6_node_type                                       Idle     11      0          11                                 
  Default (default)   d6_comment_type                                    Idle     11      0          11                                 
  Default (default)   d6_comment_field                                   Idle     11      0          11                                 
  Default (default)   d6_comment_field_instance                          Idle     11      0          11                                 
  Default (default)   d6_comment_entity_display                          Idle     11      0          11                                 
  Default (default)   d6_comment_entity_form_display                     Idle     11      0          11                                 
  Default (default)   d7_node_type                                       Idle     11      11         0             2018-12-12 17:59:21  
  Default (default)   d7_comment_type                                    Idle     11      0          11                                 
  Default (default)   d7_comment_field                                   Idle     11      0          11                                 
  Default (default)   d7_comment_field_instance                          Idle     11      0          11                                 
  Default (default)   d7_comment_entity_display                          Idle     11      0          11                                 
  Default (default)   default_language                                   Idle     0       0          0                                  
  Default (default)   d6_file                                            Idle     N/A     0          N/A                                
  Default (default)   d6_user_picture_file                               Idle     2       0          2                                  
  Default (default)   user_picture_field                                 Idle     1       1          0             2018-12-12 18:32:59  
  Default (default)   user_picture_field_instance                        Idle     1       1          0             2018-12-12 18:33:16  
  Default (default)   user_picture_entity_display                        Idle     1       0          1                                  
  Default (default)   user_picture_entity_form_display                   Idle     1       0          1                                  
  Default (default)   d6_user                                            Idle     8       0          8                                  
  Default (default)   d6_comment                                         Idle     N/A     0          N/A                                
  Default (default)   d6_comment_entity_form_display_subject             Idle     11      0          11                                 
  Default (default)   d7_comment_entity_form_display                     Idle     11      0          11                                 
  Default (default)   d7_field                                           Idle     52      0          52                                 
  Default (default)   d7_taxonomy_vocabulary                             Idle     4       4          0             2018-12-12 17:48:15  
  Default (default)   d7_field_instance                                  Idle     70      0          70                                 
  Default (default)   d7_file                                            Idle     274     0          0             2018-12-12 18:05:02  
  Default (default)   d7_user                                            Idle     8       8          0             2018-12-12 17:58:02  
  Default (default)   d7_node:article                                    Idle     124     124        0             2018-12-12 18:00:25  
  Default (default)   d7_node:blog                                       Idle     0       0          0                                  
  Default (default)   d7_node:bounce_convert_campaign                    Idle     0       0          0                                  
  Default (default)   d7_node:clients                                    Idle     0       0          0                                  
  Default (default)   d7_node:dexp_portfolio                             Idle     16      0          16                                 
  Default (default)   d7_node:gallery                                    Idle     1       0          1                                  
  Default (default)   d7_node:page                                       Idle     5       0          5                                  
  Default (default)   d7_node:slider                                     Idle     0       0          0                                  
  Default (default)   d7_node:team                                       Idle     8       8          0             2018-12-12 18:02:34  
  Default (default)   d7_node:testimonial                                Idle     8       0          8                                  
  Default (default)   d7_node:webform                                    Idle     2       2          0             2018-12-12 18:32:02  
  Default (default)   d7_node_translation:article                        Idle     0       0          0                                  
  Default (default)   d7_node_translation:blog                           Idle     0       0          0                                  
  Default (default)   d7_node_translation:bounce_convert_campaign        Idle     0       0          0                                  
  Default (default)   d7_node_translation:clients                        Idle     0       0          0                                  
  Default (default)   d7_node_translation:dexp_portfolio                 Idle     0       0          0                                  
  Default (default)   d7_node_translation:gallery                        Idle     0       0          0                                  
  Default (default)   d7_node_translation:page                           Idle     0       0          0                                  
  Default (default)   d7_node_translation:slider                         Idle     0       0          0                                  
  Default (default)   d7_node_translation:team                           Idle     0       0          0                                  
  Default (default)   d7_node_translation:testimonial                    Idle     0       0          0                                  
  Default (default)   d7_node_translation:webform                        Idle     0       0          0                                  
  Default (default)   d7_comment                                         Idle     0       0          0                                  
  Default (default)   d7_comment_entity_form_display_subject             Idle     11      0          11                                 
  Default (default)   d6_taxonomy_vocabulary                             Idle     N/A     0          N/A                                
  Default (default)   d7_field_instance_widget_settings                  Idle     70      0          70                                 
  Default (default)   d7_view_modes                                      Idle     17      0          17                                 
  Default (default)   d7_field_formatter_settings                        Idle     148     0          148                                
  Default (default)   d6_upload_field                                    Idle     1       0          1                                  
  Default (default)   d6_language_negotiation_settings                   Idle     0       0          0                                  
  Default (default)   d7_language_negotiation_settings                   Idle     0       0          0                                  
  Default (default)   d6_language_content_taxonomy_vocabulary_settings   Idle     N/A     0          N/A                                
  Default (default)   d6_node_setting_sticky                             Idle     11      0          11                                 
  Default (default)   d7_node_title_label                                Idle     11      0          11                                 
  Default (default)   d7_node_revision:article                           Idle     0       0          0                                  
  Default (default)   d7_node_revision:blog                              Idle     0       0          0                                  
  Default (default)   d7_node_revision:bounce_convert_campaign           Idle     0       0          0                                  
  Default (default)   d7_node_revision:clients                           Idle     0       0          0                                  
  Default (default)   d7_node_revision:dexp_portfolio                    Idle     0       0          0                                  
  Default (default)   d7_node_revision:gallery                           Idle     0       0          0                                  
  Default (default)   d7_node_revision:page                              Idle     0       0          0                                  
  Default (default)   d7_node_revision:slider                            Idle     0       0          0                                  
  Default (default)   d7_node_revision:team                              Idle     0       0          0                                  
  Default (default)   d7_node_revision:testimonial                       Idle     0       0          0                                  
  Default (default)   d7_node_revision:webform                           Idle     0       0          0                                  
  Default (default)   d6_node_setting_status                             Idle     11      0          11                                 
  Default (default)   d6_node_setting_promote                            Idle     11      0          11                                 
  Default (default)   d7_url_alias                                       Idle     305     305        0             2018-12-12 18:11:11  
  Default (default)   d7_rdf_mapping                                     Idle     3       0          3                                  
  Default (default)   d7_shortcut_set                                    Idle     1       0          1                                  
  Default (default)   d7_menu                                            Idle     6       6          0             2018-12-12 18:34:29  
  Default (default)   d7_menu_links                                      Idle     24      2          0             2018-12-12 18:35:05  
  Default (default)   d7_shortcut                                        Idle     2       0          2                                  
  Default (default)   d7_shortcut_set_users                              Idle     0       0          0                                  
  Default (default)   d6_menu                                            Idle     6       0          6                                  
  Default (default)   d6_taxonomy_term                                   Idle     N/A     0          N/A                                
  Default (default)   d6_vocabulary_field                                Idle     N/A     0          N/A                                
  Default (default)   d6_vocabulary_field_instance                       Idle     N/A     0          N/A                                
  Default (default)   d6_vocabulary_entity_display                       Idle     N/A     0          N/A                                
  Default (default)   d6_vocabulary_entity_form_display                  Idle     N/A     0          N/A                                
  Default (default)   d7_taxonomy_term:newsletter_categories             Idle     0       0          0                                  
  Default (default)   d7_taxonomy_term:blog_categories                   Idle     6       6          0             2018-12-12 17:55:40  
  Default (default)   d7_taxonomy_term:portfolio_category                Idle     7       7          0             2018-12-12 18:18:35  
  Default (default)   d7_taxonomy_term:tags                              Idle     120     120        0             2018-12-12 17:48:53  
  Default (default)   d6_user_contact_settings                           Idle     8       0          8                                  
  Default (default)   d6_menu_links                                      Idle     24      0          24                                 
  Default (default)   d7_custom_block_translation                        Idle     N/A     0          N/A                                
  Default (default)   d6_taxonomy_term_translation                       Idle     N/A     0          N/A                                
  Default (default)   d7_entity_reference_translation:comment__comment   Idle     N/A     0          N/A                                
  Default (default)   node_translation_menu_links                        Idle     24      0          24        

with the migration id we can migrate content types user and taxonomy terms. Download the migrate_tool module using the below command

composer require drupal/migrate_tools 

Enable the migrate_tools module

drush en -y migrate_tools 

First we need to migrate the users and then move with the taxonomy vocabulary and later with content type as the content type may contain term reference field we can avoid those errors Migation of taxonomy vocabulary can be done using the below command

drush migrate-import d7_taxonomy_vocabulary

once the taxonomy vocabulary is migrated, we can move with the term migrations. We can get the migration id with drush migrate-status and we can avoid the unwanted taxonomy terms also, as we can migrate terms with respect to each vocabulary. The below drush command will migrate the terms inside the vocabulay tags.

drush migrate-import d7_taxonomy_term:tags

Migration of content type/node creation can be done with the below command

drush migrate-import d7_node_type

Migration the artcile content can be done with below command

drush migrate-import d7_node:article

With this above simple commads we can migrate the content from Drupal 7 to Drupa 8 with half an hour.

We have done simple as well as complex drupal migration, If you are still having trouble with the content migrations, talk to a Drupal expert. Please fill in our Contact Us form and we will get back to you shortly.