New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drush sql-sync fails #668

Closed
jiv-e opened this Issue Jun 6, 2014 · 8 comments

Comments

Projects
None yet
3 participants
@jiv-e

jiv-e commented Jun 6, 2014

Here's my aliases.

$aliases['local_alias_name'] = array(
  'root' => '/local/path/to/drupal/folder',
  'uri' => 'http://local.site.url',
  'db-url' => 'mysql://db_user:password@localhost/db_name',
  'path-aliases' => array(
        '%files' => 'sites/default/files'
     ),
);

$aliases['remote_alias_name'] = array(
    'root' => '/remote/path/to/drupal/folder',
    'db-url' => 'mysql://db_user:password@localhost/db_name',
    'remote-host' => 'remote_hostname',
    'remote-user' => 'remote_user',
    'path-aliases' => array(
        '%files' => 'sites/default/files'
     ),
);

Here's the command I run:

$ drush -v sql-sync @local_alias_name @remote_alias_name

Here's the result:

...
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 @local_alias_name:/Users/jiv/drush-backups/db_name/20140606104426/db_name_20140606_104427.sql.gz /tmp/db_name_20140606_104427.sql.gz);
ssh: Could not resolve hostname local_alias_name: Name or service not known
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(605) [Receiver=3.0.9]
Could not rsync from                                                                                        [error]
@local_alias_name:/Users/jiv/drush-backups/db_name/20140606104426/db_name_20140606_104427.sql.gz
to /tmp/db_name_20140606_104427.sql.gz
Command dispatch complete                                                                       [notice]
core-rsync failed.                                                                                          [error]
Command dispatch complete                                                                       [notice]

Analysis

Drush gives @local_alias_name:/Users/... URI for rsync. It shouldn't add that @local_alias_name: at the beginning.

This started after updating to 7.0-dev drush. This was confirmed as a bug by jonhattan in the #drush IRC.

@weitzman weitzman closed this in 23c461f Jun 6, 2014

@Viveur

This comment has been minimized.

Show comment
Hide comment
@Viveur

Viveur Jun 25, 2014

I appear to be experiencing something similar to this bug.

I'm using the latest 7.0-dev version of Drush with the fix referenced already committed (i even checked to ensure the changed lines were present)

macbook:.drush me$ drush sql-sync @dev @live
You will destroy data in bit32.com/bit32 and replace with data from bit32.
Do you really want to continue? (y/n): y
Starting to dump database on Source.                                                       [ok]
Database dump saved to                                                                     [success]
/Users/me/drush-backups/bit32/20140625182840/bit32_20140625_182840.sql.gz
Starting to discover temporary files directory on Destination.                             [ok]
You will destroy data from /tmp/bit32_20140625_182840.sql.gz and replace with data from @dev:/Users/me/drush-backups/bit32/20140625182840/bit32_20140625_182840.sql.gz
Do you really want to continue? (y/n): y
ssh: Could not resolve hostname dev: Name or service not known
Could not rsync from                                                                       [error]
@dev:/Users/me/drush-backups/bit32/20140625182840/bit32_20140625_182840.sql.gz
to /tmp/bit32_20140625_182840.sql.gz
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(601) [Receiver=3.0.7]
Copying dump file from Source to Destination.                                              [ok]
core-rsync failed.                                                                         [error]
macbook:.drush me$

Viveur commented Jun 25, 2014

I appear to be experiencing something similar to this bug.

I'm using the latest 7.0-dev version of Drush with the fix referenced already committed (i even checked to ensure the changed lines were present)

macbook:.drush me$ drush sql-sync @dev @live
You will destroy data in bit32.com/bit32 and replace with data from bit32.
Do you really want to continue? (y/n): y
Starting to dump database on Source.                                                       [ok]
Database dump saved to                                                                     [success]
/Users/me/drush-backups/bit32/20140625182840/bit32_20140625_182840.sql.gz
Starting to discover temporary files directory on Destination.                             [ok]
You will destroy data from /tmp/bit32_20140625_182840.sql.gz and replace with data from @dev:/Users/me/drush-backups/bit32/20140625182840/bit32_20140625_182840.sql.gz
Do you really want to continue? (y/n): y
ssh: Could not resolve hostname dev: Name or service not known
Could not rsync from                                                                       [error]
@dev:/Users/me/drush-backups/bit32/20140625182840/bit32_20140625_182840.sql.gz
to /tmp/bit32_20140625_182840.sql.gz
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(601) [Receiver=3.0.7]
Copying dump file from Source to Destination.                                              [ok]
core-rsync failed.                                                                         [error]
macbook:.drush me$
@weitzman

This comment has been minimized.

Show comment
Hide comment
@weitzman

weitzman Jun 25, 2014

Member

Please post your @dev and @LiVe site aliases

Member

weitzman commented Jun 25, 2014

Please post your @dev and @LiVe site aliases

@Viveur

This comment has been minimized.

Show comment
Hide comment
@Viveur

Viveur Jun 26, 2014

<?php
$local_sites = '/users/me/Documents/WWW/bit32/';
$remote_sites = '/home/bit32/public_html/';

$aliases["dev"] = array (
  'root' => '/Users/me/Documents/WWW/bit32',
  'uri' => 'http://localhost:8888/bit32',
  'path-aliases' =>
  array (
    '%drush' => '/Users/me/.composer/vendor/drush/drush',
    '%sites' => 'sites/default/',
    '%dump' => $local_sites . 'sqldumps/sqldump-dev.sql',
    '%dump-dir' => $local_sites . 'sqldumps/',
  ),
  'databases' =>
  array (
    'default' =>
    array (
      'default' =>
      array (
        'database' => 'bit32',
        'username' => 'bit32',
        'password' => '',
        'host' => 'localhost',
        'port' => '3306',
        'driver' => 'mysql',
        'prefix' => '',
      ),
    ),
  ),
);
$aliases['live'] = array (
    'remote-host' => 'bit32.com',
    'remote-user' => 'bit32',
    'ssh-options' => "-p 22",
    'root' => $remote_sites,
  'uri' => 'bit32.com',
    'path-aliases' => array(
    '%drush' => '/root/.composer/vendor/drush/drush',
    '%sites' => $remote_sites . 'sites/default/',
    '%dump' => $remote_sites . 'sqldumps/sqldump-live.sql',
    '%dump-dir' => $remote_sites . 'sqldumps/',
    ),
    array (
        'default' =>
        array (
            'default' =>
            array (
                'database' => 'bit32',
                'username' => 'bit32',
                'password' => '',
                'host' => 'bit32.com',
                'port' => '3306',
                'driver' => 'mysql',
                'prefix' => '',
            ),
        ),
    ),
);
?>

Viveur commented Jun 26, 2014

<?php
$local_sites = '/users/me/Documents/WWW/bit32/';
$remote_sites = '/home/bit32/public_html/';

$aliases["dev"] = array (
  'root' => '/Users/me/Documents/WWW/bit32',
  'uri' => 'http://localhost:8888/bit32',
  'path-aliases' =>
  array (
    '%drush' => '/Users/me/.composer/vendor/drush/drush',
    '%sites' => 'sites/default/',
    '%dump' => $local_sites . 'sqldumps/sqldump-dev.sql',
    '%dump-dir' => $local_sites . 'sqldumps/',
  ),
  'databases' =>
  array (
    'default' =>
    array (
      'default' =>
      array (
        'database' => 'bit32',
        'username' => 'bit32',
        'password' => '',
        'host' => 'localhost',
        'port' => '3306',
        'driver' => 'mysql',
        'prefix' => '',
      ),
    ),
  ),
);
$aliases['live'] = array (
    'remote-host' => 'bit32.com',
    'remote-user' => 'bit32',
    'ssh-options' => "-p 22",
    'root' => $remote_sites,
  'uri' => 'bit32.com',
    'path-aliases' => array(
    '%drush' => '/root/.composer/vendor/drush/drush',
    '%sites' => $remote_sites . 'sites/default/',
    '%dump' => $remote_sites . 'sqldumps/sqldump-live.sql',
    '%dump-dir' => $remote_sites . 'sqldumps/',
    ),
    array (
        'default' =>
        array (
            'default' =>
            array (
                'database' => 'bit32',
                'username' => 'bit32',
                'password' => '',
                'host' => 'bit32.com',
                'port' => '3306',
                'driver' => 'mysql',
                'prefix' => '',
            ),
        ),
    ),
);
?>
@jiv-e

This comment has been minimized.

Show comment
Hide comment
@jiv-e

jiv-e Jun 26, 2014

I still have the same issue.

jiv-e commented Jun 26, 2014

I still have the same issue.

@jiv-e

This comment has been minimized.

Show comment
Hide comment
@jiv-e

jiv-e Jun 26, 2014

Added a related issue: #694

jiv-e commented Jun 26, 2014

Added a related issue: #694

@jiv-e

This comment has been minimized.

Show comment
Hide comment
@jiv-e

jiv-e Jun 26, 2014

After doing the fix suggested above it works better. Still the problem seems to be that the local database dump is transferred to the local machine's /tmp folder instead of the remote's one.

...
Loaded alias @local_alias_name from file /Users/jiv/.drush/sitename.aliases.drushrc.php                                                              [notice]
You will destroy data from /tmp/db_name_20140626_203108.sql.gz and replace with data from /Users/jiv/drush-backups/db_name/20140626203107/db_name_20140626_203108.sql.gz
Do you really want to continue? (y/n): y
Calling system(rsync -e 'ssh ' -rltzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --stats --progress --remove-source-files /Users/jiv/drush-backups/db_name/20140626203107/db_name_20140626_203108.sql.gz /tmp/db_name_20140626_203108.sql.gz);
...
Command dispatch complete                                          [notice]
Calling system(mysql --database=db_name --host=localhost --user=db_user --password='**********'  < /tmp/db_name_20140626_201153.sql.gz);
sh: 1: cannot open /tmp/validi_20140626_201153.sql.gz: No such file

Cannot open because it's located in the local machine's /tmp folder.

jiv-e commented Jun 26, 2014

After doing the fix suggested above it works better. Still the problem seems to be that the local database dump is transferred to the local machine's /tmp folder instead of the remote's one.

...
Loaded alias @local_alias_name from file /Users/jiv/.drush/sitename.aliases.drushrc.php                                                              [notice]
You will destroy data from /tmp/db_name_20140626_203108.sql.gz and replace with data from /Users/jiv/drush-backups/db_name/20140626203107/db_name_20140626_203108.sql.gz
Do you really want to continue? (y/n): y
Calling system(rsync -e 'ssh ' -rltzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --stats --progress --remove-source-files /Users/jiv/drush-backups/db_name/20140626203107/db_name_20140626_203108.sql.gz /tmp/db_name_20140626_203108.sql.gz);
...
Command dispatch complete                                          [notice]
Calling system(mysql --database=db_name --host=localhost --user=db_user --password='**********'  < /tmp/db_name_20140626_201153.sql.gz);
sh: 1: cannot open /tmp/validi_20140626_201153.sql.gz: No such file

Cannot open because it's located in the local machine's /tmp folder.

@jiv-e

This comment has been minimized.

Show comment
Hide comment
@jiv-e

jiv-e Jun 27, 2014

This fixes the issue for my case (sync from local to remote). Hmm... Seems like I have to do a pull request.

See:

$return = drush_invoke_process($runner, 'core-rsync', array("$source:$source_dump_path", "@self:$destination_dump_path"), $rsync_options);

Change @self to $destination:

$return = drush_invoke_process($runner, 'core-rsync', array("$source:$source_dump_path", "@self:$destination_dump_path"), $rsync_options);

Like this:

$return = drush_invoke_process($runner, 'core-rsync', array("$source:$source_dump_path", "$destination:$destination_dump_path"), $rsync_options);

I'm not sure if this solution will generate any problems in other cases.

jiv-e commented Jun 27, 2014

This fixes the issue for my case (sync from local to remote). Hmm... Seems like I have to do a pull request.

See:

$return = drush_invoke_process($runner, 'core-rsync', array("$source:$source_dump_path", "@self:$destination_dump_path"), $rsync_options);

Change @self to $destination:

$return = drush_invoke_process($runner, 'core-rsync', array("$source:$source_dump_path", "@self:$destination_dump_path"), $rsync_options);

Like this:

$return = drush_invoke_process($runner, 'core-rsync', array("$source:$source_dump_path", "$destination:$destination_dump_path"), $rsync_options);

I'm not sure if this solution will generate any problems in other cases.

@jiv-e jiv-e referenced this issue Jun 27, 2014

Closed

Issue 668 #697

@Viveur

This comment has been minimized.

Show comment
Hide comment
@Viveur

Viveur Jun 27, 2014

Appears fixed via #697

Viveur commented Jun 27, 2014

Appears fixed via #697

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment