How to run custom migration D9

Without the ability to SSH into the dev site, I’m puzzled as how to perform a custom migration. We want to relaunch existing D9 site but we do NOT want a full content migration yet. In particular, we want to migrate some taxonomy content. We’re aware of using configuration management to migrate that but not content.
The closest terminus command I see is remote:drush but I don’t expect I can run terminus remote:drush php
How would you do a custom migration?

You would create a custom module that uses the Migrate API. This page says “Drupal 8” but it’s all the same stuff for Drupal 9.

The migrate_tools module provides drush commands for running migrations. You would use that module and run your migrations with terminus drush imgrate:import <migration-name>.

For simpler migrations, you shouldn’t have to write any actual PHP code, just define migration .yml files in the config/install folder within the module.

1 Like

Hi Sam, just want to check in to make sure you have everything you need. If you still need help performing a custom migration in D9, let us know.

I also wanted to share a response from my colleague, Greg, which might be of further help to you. He said that if by “custom migration,” you meant arbitrary php scripts you write that call the Drupal API directly, then the command you want is terminus drush site.env php:script. You can either copy the php file to his site or run it from a local file via cat myfile.php | terminus drush site.env php:script -.