My apologies if this is a duplicate. I searched in the queue and have spent a couple hours trying to debug.
In short, I am trying to do an sql-sync from a production server to a development server, via the development server. Both have non-standard ports.
Here is the verbose, debug sql-sync output:
[/data/sites/dev.site.org] $ drush --debug sql-sync @prod @dev
Found command: sql-sync (commandfile=sql) [0.07 sec, 3.86 MB] [bootstrap]
Including /data/drush/commands/sql/sync.sql.inc [0.07 sec, 3.86 MB] [bootstrap]
Load alias @dev [0.07 sec, 4.04 MB] [notice]
Load alias @prod [0.07 sec, 4.05 MB] [notice]
Running: ssh -o PasswordAuthentication=no 'alan'@'site.org' 'drush --all --ssh-options='\''-p 8888'\'' --root='\''/data/sites/site.org'\'' [command]
--uri='\''site.org'\'' sql-conf --backend' [0.08 sec, 4.06 MB]
Undefined offset: 1 backend.inc:112 [0.11 sec, 4.07 MB] [notice]
Undefined variable: output backend.inc:119 [0.11 sec, 4.08 MB] [notice]
[error]ned: ssh: connect to host site.org port 22: Connection refused
, code: 255) [0.11 sec, 4.08 MB]
Running: /usr/bin/php /data/drush/drush.php --php=/usr/bin/php --all --root='/data/sites/dev.site.org' --uri='dev.site.org' sql-conf --backend [0.11 [command]
sec, 4.08 MB]
Error: no database record could be found for @prod [0.5 sec, 4.1 MB] [error]
An error occurred at function : drush_sql_sync [0.5 sec, 4.1 MB] [error]
Command dispatch complete [0.5 sec, 4.1 MB] [notice]
Peak memory usage was 4.11 MB [0.5 sec, 4.1 MB]
Here is my alias file:
/**
* @file
* Drush Aliases for Alan
*/
// QA
$aliases['qa'] = array(
'uri' => 'qa.site.org',
'root' => '/data/sites/qa.site.org',
);
// Dev
$aliases['dev'] = array(
'uri' => 'dev.site.org',
'root' => '/data/sites/dev.site.org',
);
// Production
$aliases['prod'] = array(
'uri' => 'site.org',
'root' => '/data/sites/site.org',
'remote-host' => 'site.org',
'remote-user' => 'alan',
'ssh-options' => '-p 8888',
);
And finally here is my drushrc.php file:
// $Id$
/**
* @file
* Drush settings for Alan
*/
// General Drush settings
// Turn on verbose
$options['v'] = 1;
From doing some debugging, and looking at the debug output. The port is not being specified on the ssh command to get the database settings. Though, this is confusing because sql-conf works fine.
[/data/sites/dev.site.org] $ drush --debug @prod sql-conf
Begin redispatch via backend invoke [0.08 sec, 3.97 MB] [notice]
Running: ssh -p 8888 'alan'@'site.org' 'drush --ssh-options='\''-p 8888'\'' --debug --uri='\''site.org'\'' --root='\''/data/sites/site.org'\'' [command]
sql-conf --backend' [0.08 sec, 3.98 MB]
Drush bootstrap phase : _drush_bootstrap_drush() [0.47 sec, 3.98 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.47 sec, 3.99 MB] [bootstrap]
Initialized Drupal 5.22 root directory at /data/sites/site.org [0.47 sec, 3.99 MB] [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.47 sec, 3.99 MB] [bootstrap]
Initialized Drupal site site.org at sites/default [0.47 sec, 3.99 MB] [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.47 sec, 3.99 MB] [bootstrap]
Found command: sql-conf (commandfile=sql) [0.47 sec, 3.99 MB] [bootstrap]
Command dispatch complete [0.47 sec, 3.99 MB] [notice]
Peak memory usage was 5.95 MB [0.47 sec, 3.99 MB] [memory]
Array
(
[driver] => mysql
[username] => site
[port] =>
[host] => localhost
[database] => sitedb
)
Backend invoke is complete [0.47 sec, 3.98 MB]
Any help would be much appreciated. Thanks for all the hard work and great module.
Comment | File | Size | Author |
---|---|---|---|
#9 | 820514-ssh-options.patch | 4.25 KB | greg.1.anderson |
Comments
Comment #1
greg.1.anderson CreditAttribution: greg.1.anderson commentedComment #2
geek-merlinconfirming this with 3.1
Comment #3
geek-merlintracked this down in the source and it seems to me that the crucial code is in
backend.inc:339ff (as of 3.1)
this gets hostname and username as arguments but NOT port (which is part of ssh-options *for the site*)
later on in line 363 we have
which seems to get ssh-options from commandline and NOT from sitealias.
Comment #4
geek-merlinabove analysis is supported by following observation:
adding my nonstandard port like "drush -d --ssh-options=1234sql-sync @here @there"
results in an ssh invocation with the right port.
this might be a WORKAROUND for some people
(alas in my case i get "returned: bash: drush: command not found" which surely is a separate issue (my remote drush path settings do work with "drush @there status").
Comment #5
geek-merlini just might help fix this, but i think any proper fix is likely to change signature of _drush_backend_generate_command() : we need to not only pass hostname and user, but maybe a "connection" record with hostname, user, port.
which in turn suggests to have ssh_port in setting explicitly (not in ssh_options="-p 1234"), imho.
this seems to affect not only sql-sync and make some commands kind of unusable with nonstandard port.
so changing title / category and raising prio - feel free to correct me.
Comment #6
geek-merlinas a memo the caller chain of above function:
* drush_sql_sync
* _drush_sql_sync
* sitealias_get_databases_from_record
* drush_sitealias_add_db_settings
* drush_do_site_command($alias_record, "sql-conf", array(), array('all' => TRUE))
* drush_backend_invoke_args($command, $args, $data, 'GET', $integrate, $drush_path, array_key_exists('remote-host', $site_record) ? $site_record['remote-host'] : NULL, array_key_exists('remote-user', $site_record) ? $site_record['remote-user'] : NULL);
* _drush_backend_generate_command($command, $args, $data, $method, $drush_path, $hostname, $username);
Comment #7
geek-merlinone more finding: we might also need a change like this:
@@ -1500,7 +1500,7 @@ function drush_sitealias_evaluate_path($path, &$additional_options) {
/**
* Option keys used for site selection.
*/
function drush_sitealias_site_selection_keys() {
- return array('remote-host', 'remote-user', 'name');
+ return array('remote-host', 'remote-user', 'ssh-options', 'name');
}
Comment #8
geek-merlinand last notice for today:
the workaround of #4 DOES work for me now:
"drush -d --ssh-options=1234 sql-sync @here @there"
Comment #9
greg.1.anderson CreditAttribution: greg.1.anderson commentedTry this. Regarding #5, the signature of _drush_backend_generate_command is not changed due to the use of a default value for the new parameter.
Comment #10
zzolo CreditAttribution: zzolo commentedHey @greg.1.anderson, thanks for the patch. I have tested this out and it works for me. I'll let someone else double check it before I mark as reviewed.
Comment #11
tancThanks, patch seems to fix the issue for me too.
Comment #12
zzolo CreditAttribution: zzolo commentedComment #13
greg.1.anderson CreditAttribution: greg.1.anderson commentedCommitted. Could go in 3.x too.
Comment #14
moshe weitzman CreditAttribution: moshe weitzman commentedWill roll a release soon. Committing critical backports.
Comment #18
irandream CreditAttribution: irandream commentedyes, patch seems to fix the issue for me too...thank you
طراحی وب سایت