Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Aegir: Switch Site Domains
<?php
// put in $aegirhome/.drush/siteswitch/
// run with: drush @hostmaster siteswitch "regexp" "replacepattern"
// example: drush @hostmaster siteswitch "(.*)\.yourdomain\.com" "\$1.yournewdomain.com"
function siteswitch_drush_command() {
$commands = array();
$commands['siteswitch'] = array(
'description' => dt('Run siteswitch'),
'arguments' => array('search' => 'Pattern to search for', 'replace' => 'Pattern to replace'),
);
return $commands;
$nodes = db_query('SELECT nid, title FROM {node} WHERE type="site"');
while ($site = db_fetch_array($nodes)) {
if (preg_match('/' . $search . '/', $site['title'])) {
$args = array(
'new_uri' => preg_replace('/' . $search . '/', $replace, $site['title']),
'new_db_server' => 2,
'target_platform' => 79,
);
hosting_add_task($site['nid'], 'migrate', $args);
}
}
}
@simme
Copy link
Author

simme commented Oct 16, 2012

Target platform and db server is hardcoded, make sure you change that to suite your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment