delete.backup.provision.inc 1.3 KB
Newer Older
1 2 3
<?php
/**
 * @file
4
 *   Provision hooks for the provision backup-delete command.
5 6 7
 */

/**
8
 * Provision backup-delete command
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 * These are the hooks that will be executed by the drush_invoke function
 * when deleting a backup file from the backend.
 */

function drush_provision_drupal_provision_backup_delete($backup = null) {
  if($backup) {
    $backups = explode(',', $backup);
    foreach ($backups as $filename) {
      $success =  provision_file()->unlink($filename)
       ->succeed('Removed backup file @path')
       ->fail('Could not remove backup file @path');
    }
  }
  else {
    drush_set_error(dt('No backup files provided'));
  }
}
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

/**
 * Implementation of drush_hook_post_provision_backup_delete()
 *
 * If we have a client name and backups provided, cleanup the backup
 * symlinks created for that client.
 *
 * Will not provoke a rollback if there is no symlink, for backward
 * compatibility.
 */
function drush_provision_drupal_post_provision_backup_delete($backup = null) {
  if ($backup && d()->client_name) {
    $backup_dir = d()->server->clients_path . '/' . d()->client_name . '/backups';
    $backups = explode(',', $backup);
    foreach ($backups as $filename) {
      provision_file()->unlink($backup_dir . '/' . basename($filename))
        ->succeed('Deleted backup symlink @path');
    }
  }
}