Execute a single drush command on multiple sites

greg.1.anderson - November 10, 2009 - 19:29
Project:Drush
Version:All-Versions-HEAD
Component:Code
Category:feature request
Priority:normal
Assigned:greg.1.anderson
Status:active
Description

It should be possible to execute a single drush command and have it execute on multiple sites, either local, remote, or a combination of local and remote sites. This should be done either by supplying a comma-separated list of site specifications or site aliases wherever site aliases are accepted, or by using a special site alias that represents a collection of sites.

For example:

drush dev.site1.com,dev.site2.com,dev.site3.com updatedb

or

drush all-dev updatedb

In the case of the second example, the 'all-dev' group alias is declared as follows:

$options['site-aliases']['all-dev'] = array(
  'group' => array( 'dev.site1.com', 'dev.site2.com', 'dev.site3.com')
);

A site alias is a group alias if it has a 'group' attribute but no 'uri' attribute. It is an error for an alias to have both 'group' and 'uri' attributes. A group may be made of a list of site specifications or site aliases.

It is also possible to use a group or group alias as the target of an sql sync command, like so:

drush sql sync live dev.site1.com,dev.site2.com,dev.site3.com

or

drush sql sync live all-dev

It is not possible to use a group alias as the source of an sql sync command or as the source of a sync command. The following might be supported:

drush sync \!drush all-dev:\!drush

However, it will not be possible to use group lists in the target of drush sync.

I will post a patch here when one is ready.

#1

moshe weitzman - November 10, 2009 - 20:24

It is an ongoing feature request for folks to be able to run a command on all their multi-sites. Seems like this could solve that. We could potentially have a built in 'all' which iterates over all the local sites.

#2

greg.1.anderson - November 10, 2009 - 21:05

Built-in alias groups are a great idea. Perhaps 'local' should be all of the local sites, 'remote' should be all of the remote sites, and 'all' should be all local and remote sites.

#3

SeanBannister - December 7, 2009 - 03:48

This will be an awesome feature, subscribe!

 
 

Drupal is a registered trademark of Dries Buytaert.