Created
March 27, 2012 19:16
-
-
Save kostajh/2219387 to your computer and use it in GitHub Desktop.
example.tasks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#!/usr/bin/env drush | |
// Example rebuild script | |
// local alias | |
$self_record = drush_sitealias_get_record('@self'); | |
$self_name = '@' . $self_record['#name']; | |
if (empty($self_record)) { | |
return drush_set_error('No bootstrapped site!'); | |
} else { | |
drush_print(dt('Rebuilding site for !name', array('!name' => $self_record['#name']))); | |
} | |
// prod alias | |
$prod_record = drush_sitealias_get_record('@' . $self_record['#group'] . '.prod'); | |
$prod_name = '@' . $prod_record['#name']; | |
// stage alias | |
$stage_record = drush_sitealias_get_record('@' . $self_record['#group'] . '.stage'); | |
$stage_name = '@' . $stage_record['#name']; | |
// Rsync files from production to local | |
$cmd = "drush rsync $prod_name $self_name --verbose"; | |
drush_shell_exec_interactive($cmd); | |
// Copy the database from production to local | |
$cmd = "drush sql-sync $prod_name $self_name --verbose"; | |
drush_shell_exec_interactive($cmd); | |
// Disable modules | |
$modules = array( | |
'googleanalytics', | |
); | |
foreach ($modules as $module) { | |
drush_shell_exec("drush pm-disable $module -y"); | |
} | |
// Enable modules | |
$modules = array( | |
'devel', | |
); | |
foreach ($modules as $module) { | |
drush_shell_exec("drush en $module -y"); | |
} | |
// Disable caching | |
drush_shell_exec("drush $self_name vset preprocess_js 0"); | |
drush_shell_exec("drush $self_name vset cache 0"); | |
drush_shell_exec("drush $self_name vset preprocess_css 0"); | |
drush_log('Rebuild complete', 'success'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment