Note: new drush user and very pleased. Except - I just tried out my shiny new aliases.drushrc.php file (sitting in ~/.drush/ ) by attempting to sync my local dev instance (@dev) to a staging server (@stage). When I ran drush rsync @dev @stage, everything worked as expected. When I followed up with drush sql-sync @dev @stage the command failed with a returned error from the remote bash: drush: command not found.
My aliases look like this (with private info changed):
$aliases['dev'] = array(
'uri' => 'dev',
'root' => '/Applications/MAMP/htdocs/d6',
);
$aliases['stage'] = array(
'uri' => 'stage.mystagingdomain.tld',
'root' => '/home/myuser/public_html/stage',
'remote-host' => 'mystagingdomain.tld',
'remote-user' => 'myuser',
'path-aliases' => array(
'%drush-script' => '/home/myuser/drush/drush.php',
'%dump' => '/home/myuser/sqldumps/sql_dump.sql',
'%files' => 'sites/default/files',
),
);
I've used a pushkey script to make sure my ssh key is on the remote server, and simple commands like drush @stage status work fine (and if I ssh to the staging site I can run a bunch of drush commands from there).
When I run drush -v sql-sync @dev @stage, the output is as follows:
Ardnamurchan:~ craig$ drush -v sql-sync @dev @stage
Load alias @stage [notice]
Load alias @dev [notice]
Undefined offset: 1 backend.inc:112 [notice]
Undefined variable: output backend.inc:119 [notice]
The command could not be executed successfully (returned: bash: drush: command not found [error]
, code: 127)
Error: no database record could be found for @ebcstage [error]
An error occurred at function : drush_sql_sync [error]
Command dispatch complete [notice]
Any ideas?
(Drush All-Versions-3.0 fresh out of the box yesterday; Drupal 6.16)
Comments
Comment #1
chiebert CreditAttribution: chiebert commentedTypo in my sanitised version of the verbose report: the 'Error' in the third-to-last line should refer to @stage (according to my renaming of things).
Comment #2
greg.1.anderson CreditAttribution: greg.1.anderson commentedYour configuration above will work if you install drush on the remote machine and insure that it is in the $PATH for myuser.
The other option is to include the database information in your alias record. Do this:
drush sa --show-passwords --with-db @dev
Take the 'database' record from the result and put it in your 'dev' alias. Put another 'database' record in your @stage alias definition; if you make sure that the values are correct, then you do not need to install drush on the remote machine.
Comment #4
benklocek CreditAttribution: benklocek commentedI'm having this issue also, but my host doesn't allow remote connections, so I can't add 'db-url' to my remote alias and do remote calls on the DB.
I have drush installed on the remote server and it's in $PATH, as well as defined by '%drush'. As chiebert mentioned, I can also run $drush @stage status and get the details. I can run $drush on the remote machine and everything is fine.
Would an "aliases.drushrc.php" on the server make a difference?
Comment #5
greg.1.anderson CreditAttribution: greg.1.anderson commenteddrush sql-sync
does not do remote SQL calls; it uses ssh to exec a mysql / pslq command to dump / import a file locally, which is shuttled back and forth via rsync. So, in short, you can add db-url to your remote alias if you want, and it might help things.Run with -d to get more info, including the ssh command that drush is running to dump / import the db.
Comment #6
benklocek CreditAttribution: benklocek commentedAh you are right! But as it turns out I needed to set the db-url to localhost instead of remotehost.com.
The mysql command is being run on the remote server, so localhost works great.