I have a local dev environment and a test server environment. Both are running the exact same code.

In a custom module, I added a drush hook to extend the sql_sanitize command in order to ensure all private user data is removed from the development database.

From a directory within my local environment, I can invoke drush like this:

drush sql-sanitize

And my custom drush hook is run properly.

However, when I invoke drush from the same location but targeting my remote server environment (Pantheon, if it matters, and I checked their documentation, but didn't see any relevant notes):

drush @mytestserver sql-sanitize

sql-sanitize resolves, but the custom drush hook is not called, even though the module containing the hook is enabled locally and on the test server.

I tried invoking the command from a directory outside my local dev environment, but again sql-sanitize resolved without the custom drush hook being called.

How can I execute the drush hook in a remote environment from my local machine?

I have tried both Drush 5.9 and 6.4.0.

2 Answers 2


If I understood correctly, we had a similar problem with drush < 6.4, drush was not passing the alias to the remote server if root and uri where not specified.

One way to solve it is to define $conf['root'] and $conf['uri'] in your local alias, the other is to use drush 7.


I eventually "solved" this by moving the SQL into myfile.sql and running it like this:

`drush @myalias sql-connect` < myfile.sql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.