Skip to content

Instantly share code, notes, and snippets.

@simme
Created November 11, 2010 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simme/672347 to your computer and use it in GitHub Desktop.
Save simme/672347 to your computer and use it in GitHub Desktop.
<?php
/**
* @file
* Deploy site backups as new sites on a new server.
* Duplicate platform before doing this.
*/
// Path to directory containing backups
define('BACKUP_PATH', '/var/aegir/backups');
// Date to restore yyyymmdd
define('BACKUP_DATE_RESTORE', '20101110');
// Match pattern for backup files
define('BACKUP_MATCH_PATTERN', '/^([a-z]+\.[a-z]+\.com)\-' . BACKUP_DATE_RESTORE . '.*\.tar\.gz$/');
// Drush
define('DRUSH', 'php /var/aegir/drush/drush.php');
// Platform to deploy on, written the drush way
define('PLATFORM', 'platform_subskane101');
echo "----------- Preparing deploy -----------\n";
echo "Reading backups from: " . BACKUP_PATH;
echo "\nDeploying backups from: " . BACKUP_DATE_RESTORE;
echo "-------- Starting deploy process -------\n";
$backups = new DirectoryIterator(BACKUP_PATH);
foreach ($backups as $backup) {
$file = $backup->getFilename();
$matches = array();
if (preg_match(BACKUP_MATCH_PATTERN, $file, $matches)) {
$alias_command = DRUSH . " provision-save @{$matches[1]} --context_type=site --platform=@" . PLATFORM . " --uri=$matches[1] --debug";
$deploy_command = DRUSH . " @{$matches[1]} provision-deploy " . $backup->getPathname() . " --debug";
echo "Creating site alias: {$matches[1]} \n";
echo "** Running command: {$alias_command}\n";
system($alias_command);
echo "Deploying site.\n";
echo "** Running command: {$deploy_command}\n";
system($deploy_command);
} else {
echo "Skipping {$file}.\n";
}
echo "-----------------------------------------\n\n";
}
echo "All sites deployed. Creating verify task for platform\n";
system(DRUSH . " drush @hostmaster hosting-task @" . PLATFORM . " verify --debug");
echo "Done!\n\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment