You are here

function backup_migrate_schedule::remove_expired_backups in Backup and Migrate 8.3

Same name and namespace in other branches
  1. 8.2 includes/schedules.inc \backup_migrate_schedule::remove_expired_backups()
  2. 6.3 includes/schedules.inc \backup_migrate_schedule::remove_expired_backups()
  3. 6.2 includes/schedules.inc \backup_migrate_schedule::remove_expired_backups()
  4. 7.3 includes/schedules.inc \backup_migrate_schedule::remove_expired_backups()
  5. 7.2 includes/schedules.inc \backup_migrate_schedule::remove_expired_backups()

Remove older backups keeping only the number specified by the aministrator.

1 call to backup_migrate_schedule::remove_expired_backups()
backup_migrate_schedule::run in includes/schedules.inc
Run the actual schedule.

File

includes/schedules.inc, line 672
All of the schedule handling code needed for Backup and Migrate.

Class

backup_migrate_schedule
A schedule class for crud operations.

Code

function remove_expired_backups() {
  backup_migrate_include('destinations');
  $num_to_keep = $this->keep;

  // If num to keep is not 0 (0 is infinity).
  foreach ((array) $this
    ->get_destinations() as $destination) {
    if ($destination && $destination
      ->op('delete') && ($destination_files = $destination
      ->list_files())) {
      if ($num_to_keep == BACKUP_MIGRATE_SMART_DELETE) {
        $this
          ->smart_delete_backups($destination, $destination_files, variable_get('backup_migrate_smart_keep_subhourly', BACKUP_MIGRATE_SMART_KEEP_SUBHOURLY), variable_get('backup_migrate_smart_keep_hourly', BACKUP_MIGRATE_SMART_KEEP_HOURLY), variable_get('backup_migrate_smart_keep_daily', BACKUP_MIGRATE_SMART_KEEP_DAILY), variable_get('backup_migrate_smart_keep_weekly', BACKUP_MIGRATE_SMART_KEEP_WEEKLY));
      }
      else {
        if ($num_to_keep != BACKUP_MIGRATE_KEEP_ALL) {
          $this
            ->delete_backups($destination, $destination_files, $num_to_keep);
        }
      }
    }
  }
}