9

I am trying to dump a remote Drupal site to a local SQL dump file. In Drush 8 this worked a treat:

drush @site.alias sql-dump > ~/Dumps/dumpy.2019-02-19.sql

Now, if I run this command in Drush 9 (9.4.0) I see the raw SQL just printed on the screen.

If I add 2>&1 to the command, this does not help.

If I add a --result-file= this creates a file on the remote server (not what I want).

Does anyone have any ideas here?

4
  • 3
    Please try with the latest stable Drush, 9.5.2, or better yet, try out the 9.6.0-beta3 release. If you have problems, please submit a bug report to the Drush issue queue. Commented Feb 19, 2019 at 3:15
  • Yep. I was able to dump the database locally with Drush version : 9.5.2
    – AjitS
    Commented Feb 19, 2019 at 3:46
  • 1
    heh, the Drush Github issue queue said to raise questions here. Will see if I can update Drush.
    – wiifm
    Commented Feb 20, 2019 at 0:45
  • I experience this problem with dr --version saying 9.7.1. On the remote server, it is the same version. I verified this with dr @remotealias version.
    – Gogowitsch
    Commented Oct 31, 2019 at 10:33

1 Answer 1

9

The output on the screen is caused by a bug in Drush.

From https://github.com/drush-ops/drush/issues/4004#issuecomment-479155241:

The problem is that Drush is setting tty mode even though output is redirected. This is wrong.

Workaround 1 via the command line:

drush -Dssh.tty=0 @site.alias sql-dump > ~/Dumps/dumpy.2019-02-19.sql

Workaround 2 via the YAML file that defines the remote, as suggested at https://github.com/drush-ops/drush/issues/4004#issuecomment-500157166:

For anyone coming across this issue. I had a similar problem with Drush 9.7.0 where sql:dump output was sent to standard output instead of a file. Based on the above workaround, I fixed it with the 'ssh' option in the drush alias of the remote site:

site.alias:
  ssh:
    tty: 0
3
  • Awesome.. Tried workaround1. and it worked for me. thanks !!
    – JayKandari
    Commented May 18, 2020 at 8:37
  • Using drush 10.3.5 also printed output to the screen. Used Workaround 1 to save it in the file.
    – Pradino
    Commented Dec 21, 2020 at 4:38
  • 1
    One caveat to workaround 2 is that drush @site.alias sql:cli will stop working we've discovered
    – joelpittet
    Commented Jul 5, 2022 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.