i had several test sites setup and backups enabled and backup_gc enabled

i have one rule
for backups older than 1 week, keep a backup every 1 day. however, when i deleted these test sites, the backup were still around.

CommentFileSizeAuthor
#10 hostmaster-1397798-10.patch1.15 KBdanepowell

Comments

steven jones’s picture

Title: deleting a site doesnt delete its backups » Deleting a site doesnt delete its backups
Project: Hosting backup garbage collection » Hostmaster (Aegir)
Version: 6.x-1.2 » 6.x-2.x-dev

This is an issue with Aegir itself.

Maybe we should add an option to the delete task to remove backups while we're deleting.

AquaticDisorder’s picture

@darthsteven plus one for the option.

Agreed, I'm not convinced aegir should default to deleting site backups when deleting associated sites.

One scenario I can think of would be if I deleted the wrong site accidentally and wish to restore from backup.
Another, I screwed up my site, so I delete it with the intention of restoring the most recent backup.

marafa’s picture

so .. a backup manager is what you are talking about? will it be able to do restores?

AquaticDisorder’s picture

Aegir has a restore task on the site node, however if a user were to inadvertently delete a site then that's when the backup is needed.

Aegir also has a task to delete backups on the site node, so along with garbage collection settings it's coverered really, but it wouldn't hurt to have a prompt when deleting a site I think.

Anonymous’s picture

Personally I don't think we should delete backups when we delete a site. The first person to do so accidentally will come screaming to us that it defeats the purpose of taking a backup in the first place.

I agree with #1, #2 and #4, and would consider some sort of boolean checkbox in the delete form 'delete backups too?' that is false by default.

anarcat’s picture

agreed. do not delete old site's backups by default.

especially since i think we should not backup when we disable a site, btw.

danepowell’s picture

I wrote a patch for hosting_backup_gc that deletes backups for enabled/disabled/deleted sites on separate schedules, so you can (for example) keep nightly backups of enabled sites but only a single backup of deleted sites.

The only problem is that it's apparently not possible to run the backup_delete provision task on a deleted site... in effect, once a site is deleted, if any backups still remain, there's simply no way to delete them without manually removing the file and records from the DB. Is that correct? What do people think of this solution in general?

steven jones’s picture

Hmm...good question. Not sure about how to fix this one. Maybe for certain tasks on deleted sites we need to create the context, delete the backups, delete the context.

themusician’s picture

I really like the idea of adding a checkbox to delete backups when deleting a site from Aegir. Developers, myself included on our Aegir system love to pull down live sites to our dev server, make a few changes, test and then replicate on the live site. Once this is done, we delete the site.

When we pull down a site to test the migration to a new platform a backup is automatically created and never deleted, even if we delete the site. That means we have 263 backups that I need to manually delete or nearly 28GB of data, that is never intended to be used.

The checkbox has the added benefit of giving the site owner total control of whether or not to delete all of the backups.

danepowell’s picture

StatusFileSize
new1.15 KB

@Steven Jones - should I open a new issue for this (running tasks on deleted sites)?

Specifically, the error I get when trying to run backup_delete on a deleted site is

Could not find a Drupal settings.php file at ./sites/default/settings.php

I tried to create a site context before running the backup_delete task using the attached patch, but it didn't seem to help. I could be going about this completely the wrong way- I would appreciate any guidance.

rosk0’s picture

Agreed with #5

steven jones’s picture

Title: Deleting a site doesnt delete its backups » Add option to delete backups on site delete
Category: bug » feature
chertzog’s picture

Status: Active » Needs review

What about something like this?

/**
 * Implements hook_form_FORM_ID_alter().
 */
function hosting_site_form_hosting_task_confirm_form_alter(&$form, &$form_state, $form_id){
  $node = $form_state['build_info']['args'][0];
  if($node->type == 'site' && $form['task']['#value'] == 'delete') {
    $form['delete_backups'] = array(
      '#type' => 'checkbox',
      '#title' => t('Delete site backups'),
      '#description' => t('WARNING: Checking this box will delete all backups for the site.'),
    );
    // Push the submit handler to the beginning.
    array_unshift($form['#submit'], 'hosting_site_delete_site_task_submit');
  }

}

/**
 * Submit handler for site delete form for deleting backups.
 */
function hosting_site_delete_site_task_submit($form, $form_state){
  $delete = $form_state['values']['delete_backups'];
  if ($delete) {
    $nid = $form_state['build_info']['args'][0]['nid'];
    hosting_add_task($nid,'backup-delete');
  }
}

Because we pushed the submit handler to the beginning of the #submit array, the delete backups task should run before the delete task, thus have no issue with drush aliases (assuming im understanding things correctly.

ergonlogic’s picture

I think you'd need to iterate over all the site's backups. So you'd need to make sure they all get queued before the site delete task. But otherwise, this looks like the right approach.

anarcat’s picture

Status: Needs review » Needs work
ergonlogic’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Issue summary: View changes

New features need to be implemented in Aegir 3.x, then we can consider back-porting to Aegir 2.x.

marafa’s picture

so now we are talking about an option to delete backups on site delete. the question is, what happens to the backups if they arent deleted at site deletion?

will they age normally and be cleaned up by backup_gc? we dont need them lying around taking up space. so, if the rule says keep them around for a week, that rule should be valid even if the site has been deleted.

ergonlogic’s picture

The solution in #13 looks pretty close. It might be nice to have a global option too. Something along the lines of:

Delete backups when a site is deleted?
[] Always
[] Prompt
[] Never

Also, by deleting the backups first, we'll still have the final pre-delete backup available as a safety-net.

ergonlogic’s picture

Status: Needs work » Fixed
themusician’s picture

Hooray :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.