Commit 1edd757f authored by anarcat's avatar anarcat

1047992 - exportable backups in client homes

parent 5609c8a2
......@@ -112,6 +112,13 @@ function drush_provision_drupal_provision_backup() {
function drush_provision_drupal_post_provision_backup() {
drush_log(dt('Backed up site up to @path.', array('@path' => drush_get_option('backup_file'))), 'success');
if (d()->client_name) {
$backup_dir = d()->server->clients_path . '/' . d()->client_name . '/backups';
provision_file()->create_dir($backup_dir, dt('Client backup directory for @client', array('@client' => d()->client_name)), 0750);
provision_file()->symlink(drush_get_option('backup_file'), $backup_dir . '/' . basename(drush_get_option('backup_file')))
->succeed('Created symlink @path to @target')
->fail('Could not create symlink @path to @target: @reason');
}
}
/**
......
......@@ -24,3 +24,23 @@ function drush_provision_drupal_provision_backup_delete($backup = null) {
drush_set_error(dt('No backup files provided'));
}
}
/**
* 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');
}
}
}
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