Can drush take piping commands for a multisite command using an alias?

I'm trying to setup a simple refresh function from my prod to dev/staging. Any pointers or tips would be welcome. just started learning this stuff.

drush $prodalias sql-dump --gzip >/tmp/$site.sql.gz

gunzip /tmp/$site.sql.gz | drush $devalias sqlc

2 Answers 2


I write bash/shell scripts involving Drush all the time. If it's just the variables you're interested in, that has nothing to do with Drush and works fantastically. As for piping, I i'm not too sure what all is supported.

For bash to interpret your variables, you just need to wrap them in quotes.



# Check if we have both a source and a destination.
if [ -z "$dest"]; then
  # Looks like at least one of our parameters are missing, notify and exit.
  echo "A source and destination Drush alias is required."
  exit 1

drush sql-sync "$source" "$dest"


./my-sync-script.sh @alias.prod @alias.dev

It should be allowed to use piping in drush aliases as this feature was added recently by improving escaping options for core-exec.

So you have to upgrade your drush to the recent version (7.x).

See: Are pipes allowed in shell aliases?

If you prefer to use script, here is one which I'm usually using:

# pull-db.sh
# Script to pull the database from remote to local environment.
[ -z "$1" ] && { echo "Usage: $0 @remote (args)"; exit 1; }
drush $SRC sql-dump | drush $* sql-cli

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.