Skip to content

Instantly share code, notes, and snippets.

@bangpound
Created May 30, 2012 20:41
Show Gist options
  • Save bangpound/2838819 to your computer and use it in GitHub Desktop.
Save bangpound/2838819 to your computer and use it in GitHub Desktop.
Drush policy file to prevent catastrophes on live environments.
<?php
/**
* Implement of drush_hook_COMMAND_validate().
*
* Prevent catastrophic sql-sync to live. Note that this file has to be local to the
* machine that intitiates sql-sync command.
*/
function drush_policy_sql_sync_validate($source = NULL, $destination = NULL) {
if (strstr($destination, '.live')) {
return drush_set_error(dt('You may never overwrite the production database.'));
}
}
/**
* Implement of drush_hook_COMMAND_validate().
*
* Prevent catastrophic rsync to live. Note that this file has to be local to the machine
* that intitiates sql-sync command.
*/
function drush_policy_core_rsync_validate($source = NULL, $destination = NULL) {
if (strstr($destination, '.live')) {
return drush_set_error(dt('You may never overwrite the production files.'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment