You are here

function backup_migrate_schedules_run in Backup and Migrate 5.2

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

Run the preconfigured schedules. Called on cron.

1 call to backup_migrate_schedules_run()
backup_migrate_cron in ./backup_migrate.module
Implementation of hook_cron().

File

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

Code

function backup_migrate_schedules_run() {
  require_once './' . drupal_get_path('module', 'backup_migrate') . '/includes/profiles.inc';
  foreach (backup_migrate_get_schedules() as $schedule) {
    $now = time();
    if ($schedule['enabled'] && $schedule['last_run'] < $now - $schedule['period']) {
      if ($settings = backup_migrate_get_profile($schedule['profile_id'])) {
        $settings['destination_id'] = $schedule['destination_id'];
        backup_migrate_perform_backup($settings);
        _backup_migrate_schedule_set_last_run($schedule['schedule_id'], $now);
        _backup_migrate_schedule_remove_expired_backups($schedule['destination_id'], $schedule['keep']);
      }
      else {
        _backup_migrate_message("Schedule '%schedule' could not be run because requires a profile which is missing.", array(
          '%schedule' => $schedule['name'],
        ), 'error');
      }
    }
  }
}