If I try to run this from msysgit Git Bash terminal:

$ drush sql-dump  --result-file="C:\wamp\www\test.sql" --gzip
mysqldump: Couldn't find table: ";"
Database dump failed

However, if I leave out the --gzip, it works, although obviously the sql file is not compressed

So this works to do it separately:

$ drush sql-dump  --result-file="C:\wamp\www\test.sql"
Database dump saved to C:\wamp\www\test.sql

$ gzip c:/wamp/www/test.sql

Gzip created the test.sql.gz as expected, so my $PATH is working.

Interestingly, this also works to create the test.sql file without errors:

$ mysqldump -u root dbname  > c:/wamp/www/test.sql

Comments

greg.1.anderson’s picture

Issue tags: +Windows

This is probably an escaping issue on Windows; it would be useful to see the --debug output, per the issue submission guidelines, although this is probably easy to reproduce. Adding the 'Windows' tag.

JSCSJSCS’s picture

Debug output:

$ drush sql-dump  --result-file=../testmdj.sql --gzip --debug
Bootstrap to phase 0. [0.03 sec, 2.43 MB]                            [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.06 sec, 2.58 MB] [bootstrap]
Cache HIT cid: 5.0-commandfiles-0-6cbde9fdeca45e30d18516e261ef1ff6 [0.28 sec, 2.59 MB]                           [debug]

Bootstrap to phase 0. [0.37 sec, 5.46 MB]                                                                    [bootstrap]

Bootstrap to phase 0. [0.4 sec, 5.46 MB]                                                                     [bootstrap]

Found command: sql-dump (commandfile=sql) [0.41 sec, 5.46 MB]                                                [bootstrap]

Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.47 sec, 5.49 MB]                                   [bootstrap]

Initialized Drupal 7.12 root directory at c:/wamp/www/local.sitename.com [0.54 sec, 7.65 MB]             [notice]

Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.56 sec, 7.66 MB]                                   [bootstrap]

Initialized Drupal site default at sites/default [0.56 sec, 7.66 MB]                                            [notice]

Cache HIT cid: 5.0-commandfiles-2-1c82782e4f0daa661b06df029df9c6f1 [0.63 sec, 7.66 MB]                           [debug]

Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.7 sec, 8.28 MB]                           [bootstrap]

Cache HIT cid: 5.0-commandfiles-3-d970728376beb137057865c63baa822f [0.71 sec, 8.28 MB]                           [debug]

Calling system(mysqldump --result-file ../testmdj.sql --no-autocommit --single-transaction --opt -Q  databasename --host=localhost --user=root --password= ; gzip ../testmdj.sql);
mysqldump: Couldn't find table: ";"
Database dump failed [2.76 sec, 8.28 MB]                                                                         [error]

Command dispatch complete [2.77 sec, 8.26 MB]                                                                   [notice]

 Timer  Cum (sec)  Count  Avg (msec)
 page   2.081      1      2080.81

Peak memory usage was 8.34 MB [2.8 sec, 8.26 MB]                                                                [memory]

From this I can see that drush is calling:

mysqldump --result-file ../testmdj.sql --no-autocommit --single-transaction --opt -Q  databasename --host=localhost --user=root --password= ; gzip ../testmdj.sql

Which works if I enter it directly, but not if I enter:

drush sql-dump  --result-file=../testmdj.sql --gzip

Maybe it has something to do with no password in the local MySQL root account? I would think Drush can handle that though. Maybe it has something to do with the ; after the password that works with mysqldump, but not when it is passed through DRUSH's call?

greg.1.anderson’s picture

; is the command separator on Linux (and in the msysgit bash shell), but it apparently is not recognized as such on Windows. Maybe && would work better -- or does this have to be & on Windows? You'll have to test by changing the Drush code, or try it in DOS or PowerShell. No time to check right now, but we might already have a "command separator" concept in Drush. If not, we should probably add it.

JSCSJSCS’s picture

As you suggested, I changed sql.drush.inc

  if (drush_get_option('gzip')) {
    if ($file) {
      // Gzip the result-file
      $exec .= "; gzip $file";
      $file .= '.gz';
    }
    else {
      // gzip via pipe since user has not specified a file.
      $exec .= "| gzip";
    }

to:

  if (drush_get_option('gzip')) {
    if ($file) {
      // Gzip the result-file
      $exec .= " && gzip $file";
      $file .= '.gz';
    }
    else {
      // gzip via pipe since user has not specified a file.
      $exec .= "| gzip";
    }

and initially it is working

greg.1.anderson’s picture

Traditionally, Drush has avoided the pipe operator because it reportedly uses more RAM than multi-step operations, which can be a problem on small hosted sites. I have not verified this assumption myself, but it has been policy.

moshe weitzman’s picture

Status: Active » Fixed

committed proposed fix ... the pipe code is unchanged in the proposal.

Automatically closed -- issue fixed for 2 weeks with no activity.