Thanks to adrian in #783642: Code to use drush to enqueue Aegir tasks for enabled sites, just as if it had been done via the ui, we can now enqueue (or requeue) real tasks from the backend:

drush @hostmaster hosting-task verify

But tasks like migrate or clone require arguments to function properly, which hosting-task doesn't support. This needs to be done for this feature to be really really cool and complete.

#6 hostmaster-1003536-task-args.patch1.24 KBSteven Jones


Steven Jones’s picture

Yup, it does. I came across this limitation, and it's a bit of a pain to workaround.


Robin Millette’s picture


tema’s picture

me too )

Steven Jones’s picture

Project: Hosting » Hostmaster (Aegir)
Version: 6.x-0.4-alpha3 » 6.x-2.x-dev
Component: User interface » Code
Priority: Normal » Major

Would love to have this.

Steven Jones’s picture

Assigned: Unassigned » Steven Jones

I need this, I don't think we can just grab the arguments directly from the command line, because they would also be used as arguments for the hosting-task command itself, which might have unexpected consequences. My current thinking is that we should just allow an additional option: --task-arguments that accepts a JSON encoded array of arguments to pass directly into the task. This way we don't get any clashing. There is some precedent for using JSON to pass stuff around in Drush, that's how the backend invoke stuff works and can return data.

Steven Jones’s picture

Assigned: Steven Jones » Unassigned
Status: Active » Needs work
1.24 KB

So you can allow passing of the task args quite easily acutally, see the attached patch. But it's not actually much use, because the possible arguments are not defined anywhere, so you can't get default values etc. We should tighten the API in 2.x, also you can't really use it anyway, because most of the arguments are using internal hostmaster node IDs, instead of the context machine names, so we are expecting people using the command line to know the node IDs for the platforms they want etc. which is just silly.

This patch does work nicely for creating backup tasks with specific descriptions etc.

gmania’s picture

We needed to be able to migrate from the command line as part of our "lite" continuous integration approach

This should be part of aegir core, but for now, Drush script to the rescue!

The following drush script takes as arguments the name of the site to migrate, and the name of the target platform, and looks up all the information needed to add a hosting migrate task to the front-end, and migrate the site on the backend. Since aegir tasks happen asynchronously, we also added a waiting period of up to 10 minutes for the platform to be available, since in the case of our automated deployment, we need to give it time to build

Here’s the drush script. Just add it anywhere in your /var/aegir directory (remember to chmod u+x it so that it can be run from the shell)


#!/usr/bin/env drush

//Drush script to migrate a site from the command line

//Provide site name and target platform name from the command line
$site_name = drush_shift();
$platform_name = drush_shift();

//Lookup site  
$sql = "SELECT nid FROM node where title = '%s' AND type = 'site';";
$result = db_query($sql, $site_name);
while ($row = db_fetch_array($result)) {
  $site_nid = $row['nid'];

if (!$site_nid) {
  drush_set_error('INVALID_SITE', "Specified site cannot be found");

//Lookup platform  
$sql = "SELECT nid FROM node where title = '%s' AND type = 'platform'";
$result = db_query($sql, $platform_name);
while ($row = db_fetch_array($result)) {
  $platform_nid = $row['nid'];

if (!$platform_nid) {
  drush_set_error('INVALID_PLATFORM', "Specified target platform cannot be found");

#load full site details so we can add to migrate task
$site = node_load($site_nid);

#Confirm if platform is online, if not, wait

$timeout = 600;
$online = FALSE;
$start_time = time();
while (!$online) {

  //Get platform readiness
  $sql = "SELECT status FROM hosting_platform WHERE nid = %d AND status = 1";
  $result = db_query($sql, $platform_nid);
  while ($row = db_fetch_array($result)) {
      $online = $row['status'];
  //If we're not yet online, sleep for 15 seconds, unless we've already hit our timeout
  if (!$online) {
    if (time() - $start_time > $timeout) {
      drush_set_error('PLATFORM_TIMEOUT', "Target migration platform was not ready within timeout period of $timeout seconds");

//Platform must be online, so we can continue with the migrate

hosting_add_task($site_nid, 'migrate', array(
    'target_platform' => $platform_nid,
    'new_uri' => $site->title,
    'new_db_server' => $site->db_server,

To run it, call it within the hostmaster context:

/var/aegir/makes/migrate.drush @hostmaster SITE_TO_MIGRATE TARGET_PLATFORM

ergonlogic’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Issue summary: View changes

New features need to be implemented in Aegir 3.x, then we can consider back-porting to Aegir 2.x.

helmo’s picture

Status: Needs work » Closed (duplicate)