Monitoring a Drupal 8 Migration Executed with Drush

Update 2 is proving to be the most useful method.

Update 1

Somehow I missed the documentation regarding the --feedback  argument for the drush mi  command. It’s similar to the methods below in that it helps you see that the migration is working, though you don’t see the totals. You can ask for feedback in seconds or items.

Update 2:

Another method that is a bit dirty but very useful is to add a single line to core/modules/migrate/src/MigrateExecutable.php.

Adding the highlighted line to \Drupal\migrate\MigrateExecutable::import will let you see exactly where the migration is (which row is being processed).

If this is something you want permanently, consider posting an issue on d.o to request more verbose logging. This is my hackey solution for my immediate needs.

The output (in your logs, and in the drush output) will be something like this (institution_node is my migration, inst_guid is the only id):

As of Thursday, August 16, 2018 the counter() method is removed. So, you have to drop a counter variable in place like this:

This method of monitoring execution is surprisingly effective as it’s fast and you don’t have to lift a finger for it to happen each time you run a migration.

Original Post

This isn’t exactly an ideal solution, but it will do in a pinch. I’m working on a migration of more than 46,000 nodes (in a single migration among many). I needed a way to monitor the progress but I wanted to do it as quickly as possible (no coding). Here’s what I came up with, which I run in a new iTerm window.

All we’re doing is asking how many records are in the “member_node” migration map every 5 seconds. If we started at 6350 items we know that by the end of 20 seconds we have created 35 records.

We could also query the target content type itself:

Here we can analyze the data the same way to see how many records the migration is creating.

I recognize that this is pretty crude, but it’s effective; you are able to see that it’s working, instead of just staring at an unchanging prompt and watching your CPU jump.

Leave a Reply

Your email address will not be published.