drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.33k stars 1.08k forks source link

sql-sync failing to pass correct $source to core-rsync #2047

Open a-fro opened 8 years ago

a-fro commented 8 years ago

I'm having a strange issue with sql-sync since upgrading to 8.0.3 (from 8.0.1). The command works fine with my Acquia remotes, but hits an ssh public key failure with a different source on a testing server.

I can see from the debug statement that the remote gets passed correctly when I use the Acquia alias, but not when I use the testing alias. With the latter, the source is being passed as the alias name, rather than using the specified remote-host and remote-user settings. If I take the failing core-rsync command (something like rsync -e 'ssh ' -akzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --stats --progress --remove-source-files @alias.name:/var/www/drush-backups/db/20160301203012/db_20160301_203014.sql.gz /tmp/db_20160301_203014.sql.gz) and replace @alias.name with user@domain.com, it works. Somehow, the remote-host and remote-user settings are being ignored, but only in the rsync command. I tried passing the correct user via ssh-options as suggested in #1803, but that causes drush_sqlsync_sql_sync_validate to fail, since it already has the correct source.

weitzman commented 8 years ago

Need a full log with --verbose. Also provide all involved site aliases involved. Also note what version of Drush is running on each side of the sql-sync

a-fro commented 8 years ago

Here's the log with the verbose flag:

    drush sql-sync @domain.prod @domain.local -y --verbose
    Loaded alias @domain.local from file /Users/aaron/Vagrant/sitename/docroot/sites/all/drush/projecname.aliases.drushrc.php                                  [notice]
    Loaded alias @domain.prod from file /Users/aaron/Vagrant/sitename/docroot/sites/all/drush/domain.aliases.drushrc.php                       [notice]
    ssh -o PasswordAuthentication=no ubuntu@domain.com 'env COLUMNS=160 drush  --backend=2 --verbose --yes --uri=prod.projecname.domain.com              [notice]
    --root=/var/aegir/projects/projectname/prod/docroot  sql-conf   --all 2>&1' 2>&1
    /usr/local/php5/bin/php /Users/aaron/.composer/vendor/drush/drush/drush.php --php=/usr/local/php5/bin/php  --backend=2 --verbose --yes                  [notice]
    --uri=http://www.sitename.dev --root=/Users/aaron/Vagrant/sitename/docroot  sql-conf   --all 2>&1
    You will destroy data in dbname and replace with data from domain.com/dbname.
    Do you really want to continue? (y/n): y
    Starting to dump database on Source.                                                                                                                 [ok]
    ssh -o PasswordAuthentication=no ubuntu@domain.com 'env COLUMNS=160 drush  --backend=2 --verbose --yes --strict=0                                  [notice]
    --root=/var/aegir/projects/projectname/prod/docroot --uri=prod.projecname.domain.com  sql-dump   --gzip --result-file 2>&1' 2>&1
    Initialized Drupal 7.43 root directory at /var/aegir/projects/projectname/prod/docroot                                                                          [notice]
    Initialized Drupal site prod.projecname.domain.com at sites/prod.projecname.domain.com                                                                      [notice]
    /usr/bin/php  -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off /usr/share/composer/vendor/drush/drush/drush.php           [notice]
    --php=/usr/bin/php --php-options=' -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off'  --backend=2
    --root=/var/aegir/projects/projectname/prod/docroot --uri=prod.projecname.domain.com  sql-query 'SHOW TABLES' 2>&1
    Command dispatch complete                                                                                                                               [notice]
    Calling system(mysqldump --result-file /home/ubuntu/drush-backups/dbname/20160303151557/dbname_20160303_151557.sql --no-autocommit --single-transaction --opt -Q  dbname --host=localhost --user=dbname --password=xxxxxxxxx --port=3306  && gzip -f /home/ubuntu/drush-backups/dbname/20160303151557/dbname_20160303_151557.sql);
    Database dump saved to /home/ubuntu/drush-backups/dbname/20160303151557/dbname_20160303_151557.sql.gz                            [success]
    Command dispatch complete                                                                                                                               [notice]
    Starting to discover temporary files directory on Destination.                                                                                       [ok]
    /usr/local/php5/bin/php /Users/aaron/.composer/vendor/drush/drush/drush.php --php=/usr/local/php5/bin/php  --backend=2 --verbose --yes                  [notice]
    --root=/Users/aaron/Vagrant/sitename/docroot --uri=http://www.sitename.dev  core-status 2>&1
    /usr/local/php5/bin/php /Users/aaron/.composer/vendor/drush/drush/drush.php --php=/usr/local/php5/bin/php  --backend=2 --yes --verbose                  [notice]
    --root=/Users/aaron/Vagrant/sitename/docroot --uri=http://default  core-rsync
    '@domain.prod:/home/ubuntu/drush-backups/dbname/20160303151557/dbname_20160303_151557.sql.gz'
    '@domain.local:/tmp/dbname_20160303_151557.sql.gz'   --remove-source-files 2>&1
    Loaded alias @domain.local from file /Users/aaron/Vagrant/sitename/docroot/sites/all/drush/projecname.aliases.drushrc.php                                  [notice]
    You will destroy data from /tmp/dbname_20160303_151557.sql.gz and replace with data from @domain.prod:/home/ubuntu/drush-backups/dbname/20160303151557/dbname_20160303_151557.sql.gz
    Do you really want to continue? (y/n): y
    Calling system(rsync -e 'ssh ' -akzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --stats --progress --remove-source-files @domain.prod:/home/ubuntu/drush-backups/dbname/20160303151557/dbname_20160303_151557.sql.gz /tmp/dbname_20160303_151557.sql.gz);
    ssh: connect to host @domain.prod port 22: Operation timed out
    rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
    rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.1]
    Could not rsync from @domain.prod:/home/ubuntu/drush-backups/dbname/20160303151557/dbname_20160303_151557.sql.gz to         [error]
    /tmp/dbname_20160303_151557.sql.gz
    Command dispatch complete                                                                                                                               [notice]
    Copying dump file from Source to Destination.                                                                                                        [ok]
    core-rsync failed.                                                                                                                                   [error]
    Command dispatch complete                                                       

And here is the alias:

    $aliases[prod] = array(
      'uri' => prod.projectname.domain.com',
      'root' => '/var/aegir/projects/projectname/prod/docroot',
      'remote-host' => 'domain.com',
      'remote-user' => 'ubuntu',
      'path-aliases' => array (
        '%dump-dir' => '/tmp',
      ),
    );

As you can see, the site is running on Aegir, so the drush version is 6.7.0, while locally I'm running 8.0.3.

weitzman commented 8 years ago

Not sure why that alias name is not replaced. I just committed a fix to 8.x which probably wont matter but you could update to dev-master locally and try again.

a-fro commented 8 years ago

Updated, but still happening. Please let me know if there's anything I can do to help troubleshoot.

weitzman commented 8 years ago

I dont know. There is only so much effort one can dedicate to hosts which still run drush6. I know you have to do that for Aegir, but it means we can't support you well here.

My parting suggestion is to make sure that the @domain.prod alias is also defined on the remote host. Maybe thats required for your setup (needs research).

gaelg commented 7 years ago

This might help ? https://gist.github.com/gaelg/bfed6ddafb4dcc7a45ef2d264ab782e6