Commit f8545ace authored by ergonlogic's avatar ergonlogic Committed by helmo

Issue #2731471 by Jon Pugh, ergonlogic: Provision backup-delete command is too...

Issue #2731471 by Jon Pugh, ergonlogic: Provision backup-delete command is too strict if it doesn't have "backups" passed to it
parent f6c152ba
...@@ -9,32 +9,33 @@ ...@@ -9,32 +9,33 @@
* *
* These are the hooks that will be executed by the drush_invoke function * These are the hooks that will be executed by the drush_invoke function
* when deleting a backup file from the backend. * when deleting a backup file from the backend.
*
* @param string $backup
* A comma-separated list of backup filenames.
*/ */
function drush_provision_drupal_provision_backup_delete($backup = NULL) { function drush_provision_drupal_provision_backup_delete($backup) {
if ($backup) { $backups = explode(',', $backup);
$backups = explode(',', $backup); foreach ($backups as $filename) {
foreach ($backups as $filename) { $success = provision_file()->unlink($filename)
$success = provision_file()->unlink($filename) ->succeed('Removed backup file @path')
->succeed('Removed backup file @path') ->fail('Could not remove backup file @path');
->fail('Could not remove backup file @path');
}
}
else {
drush_set_error(dt('No backup files provided'));
} }
} }
/** /**
* Implements drush_hook_post_COMMAND(). * Implements drush_hook_post_COMMAND().
* *
* If we have a client name and backups provided, cleanup the backup * If we have a client name, cleanup the backup symlinks created for that
* symlinks created for that client. * client.
* *
* Will not provoke a rollback if there is no symlink, for backward * Will not provoke a rollback if there is no symlink, for backward
* compatibility. * compatibility.
*
* @param string $backup
* A comma-separated list of backup filenames.
*/ */
function drush_provision_drupal_post_provision_backup_delete($backup = NULL) { function drush_provision_drupal_post_provision_backup_delete($backup) {
if ($backup && d()->client_name) { if (d()->client_name) {
$backup_dir = d()->server->clients_path . '/' . d()->client_name . '/backups'; $backup_dir = d()->server->clients_path . '/' . d()->client_name . '/backups';
$backups = explode(',', $backup); $backups = explode(',', $backup);
foreach ($backups as $filename) { foreach ($backups as $filename) {
......
...@@ -282,6 +282,7 @@ function provision_drush_command() { ...@@ -282,6 +282,7 @@ function provision_drush_command() {
$items['provision-backup-delete'] = array( $items['provision-backup-delete'] = array(
'description' => 'Delete a backup file.', 'description' => 'Delete a backup file.',
'arguments' => array('backup-file' => dt('The backup file to delete. This will be a gzipped tarball.')), 'arguments' => array('backup-file' => dt('The backup file to delete. This will be a gzipped tarball.')),
'required-arguments' => TRUE,
'examples' => array( 'examples' => array(
'drush @site provision-backup-delete /path/to/site_backup.tgz' => 'Delete a backup of this site as defined by the site Drush alias generated with provision-save.', 'drush @site provision-backup-delete /path/to/site_backup.tgz' => 'Delete a backup of this site as defined by the site Drush alias generated with provision-save.',
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment