You are here

function backup_migrate_schedule::cron in Backup and Migrate 8.2

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

Perform the cron action. Run the backup if enough time has elapsed.

File

includes/schedules.inc, line 331

Class

backup_migrate_schedule
A schedule class for crud operations.

Code

function cron() {
  $now = time();

  // Add a small negative buffer (1% of the entire period) to the time to account for slight difference in cron run length.
  $wait_time = $this->period - $this->period * variable_get('backup_migrate_schedule_buffer', 0.01);
  if ($this
    ->is_enabled() && $now - $this
    ->get('last_run') >= $wait_time) {
    if ($settings = $this
      ->get_profile()) {
      $settings->destination_id = $this->destination_id;
      $settings->source_id = $this->source_id;
      backup_migrate_perform_backup($settings);
      $this
        ->update_last_run($now);
      $this
        ->remove_expired_backups();
    }
    else {
      backup_migrate_backup_fail("Schedule '%schedule' could not be run because requires a profile which is missing.", array(
        '%schedule' => $schedule
          ->get_name(),
      ), $settings);
    }
  }
}