4

I use drush site aliases and drush sql-sync as part of my daily workflow between my local development environment and my company's production/staging servers (Acquia dev cloud). This works great for single site instances, but I haven't been able to get it to work with multisites.

Example site structure for my @remote alias:

@remote
  - default.com ``drush @remote`` <-- commands not targeted with `-l` execute here
  - sitename.com ``drush @remote -l sitename.com status``
  - foobar.com ``drush @remote -l foobar.com sql-connect``

For other drush commands, I can target the multisite that I want use the -l switch to specify a particular multisite, and I get the correct output for drush status and drush sql-connect (correct URI and Database name).

However, when I try to use -l with drush sql-sync, it just targets the root site, no matter what. I can get around this by manually dumping the database and doing drush sql-cli @remote -l multisite.com < db.sql, but it's not half as quick as just doing drush sql-sync @local -l sitename.com @drush.remote -l sitename.com

I can open up a drush issue queue if this is a bug, but I'm wanted to check and see if I was doing something wrong first. Thanks!

  • Why not just set up a different alias for each of the sites in the multisite? Then you can address the alias directly rather than use -l. I have a similar setup and sql-sync works great for me – Clive Apr 26 '13 at 16:07
5

It is true that mixing @alias and -l together does happen to work in the local case, but is not supported in sql-sync. If this did work, you would need to use --target-uri and --source-uri to distinguish the two different -l/--uri options, but this has never been implemented. Drush always uses the source and target alias records, and nothing else, to determine how to look up the source and target database records.

As Clive says, the best thing to do it so set up separate aliases for each site. If you put all of your aliases in a single file, they will automatically create an alias group.

For example, I do something like this:

sitename.aliases.drushrc.php:

<?php

$aliases['live'] = array (
  'parent' => '@server.urpad',
  'root' => '/srv/www/sitename/htdocs',
  'uri' => 'http://sitename.com',
}

$aliases['dev'] = array (
  'root' => '/srv/www/sitename/htdocs',
  'uri' => 'http://sitename.com',
}

server.aliases.drushrc.php:

<?php

$aliases['urpad'] = array (
  'remote-host' => 'my.remote-server.org',
  'remote-user' => 'www-admin',
}

Using a 'server' alias file allows me to easily specify where I want to put each remote site without having to duplicate the remote host information.

Then, to use it:

drush sql-sync @sitename.live @sitename.dev

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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