Skip to content

Commit

Permalink
MDL-37181 backup: stopped setting the status of unscheduled backups t…
Browse files Browse the repository at this point in the history
…o skipped
  • Loading branch information
mdjnelson committed Oct 9, 2013
1 parent 22084d5 commit 8580fba
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions backup/util/helper/backup_cron_helper.class.php
Expand Up @@ -133,19 +133,23 @@ public static function run_automated_backup($rundirective = self::RUN_ON_SCHEDUL
$backupcourse->laststatus == self::BACKUP_STATUS_OK) && (
$backupcourse->laststarttime > 0 && $backupcourse->lastendtime > 0);

// Skip courses that do not yet need backup.
$skipped = !(($backupcourse->nextstarttime > 0 && $backupcourse->nextstarttime < $now) || $rundirective == self::RUN_IMMEDIATELY);
$skippedmessage = 'Does not require backup';
// Assume that we are not skipping anything.
$skipped = false;
$skippedmessage = '';

// Check if we are going to be running the backup now.
$shouldrunnow = (($backupcourse->nextstarttime > 0 && $backupcourse->nextstarttime < $now)
|| $rundirective == self::RUN_IMMEDIATELY);

// If config backup_auto_skip_hidden is set to true, skip courses that are not visible.
if (!$skipped && $config->backup_auto_skip_hidden) {
if ($shouldrunnow && $config->backup_auto_skip_hidden) {
$skipped = ($config->backup_auto_skip_hidden && !$course->visible);
$skippedmessage = 'Not visible';
}

// If config backup_auto_skip_modif_days is set to true, skip courses
// that have not been modified since the number of days defined.
if (!$skipped && $lastbackupwassuccessful && $config->backup_auto_skip_modif_days) {
if ($shouldrunnow && !$skipped && $lastbackupwassuccessful && $config->backup_auto_skip_modif_days) {
$sqlwhere = "course=:courseid AND time>:time AND ".$DB->sql_like('action', ':action', false, true, true);
$timenotmodifsincedays = $now - ($config->backup_auto_skip_modif_days * DAYSECS);
// Check log if there were any modifications to the course content.
Expand All @@ -160,7 +164,7 @@ public static function run_automated_backup($rundirective = self::RUN_ON_SCHEDUL

// If config backup_auto_skip_modif_prev is set to true, skip courses
// that have not been modified since previous backup.
if (!$skipped && $lastbackupwassuccessful && $config->backup_auto_skip_modif_prev) {
if ($shouldrunnow && !$skipped && $lastbackupwassuccessful && $config->backup_auto_skip_modif_prev) {
// Check log if there were any modifications to the course content.
$params = array('courseid' => $course->id,
'time' => $backupcourse->laststarttime,
Expand All @@ -171,16 +175,17 @@ public static function run_automated_backup($rundirective = self::RUN_ON_SCHEDUL
$skippedmessage = 'Not modified since previous backup';
}

// Skip courses not needed for backup.
if ($skipped) {
// Output the next execution time when it has been updated.
if ($backupcourse->nextstarttime != $nextstarttime) {
mtrace('Backup of \'' . $course->fullname . '\' is scheduled on ' . $showtime);
}
// Check if the course is not scheduled to run right now.
if (!$shouldrunnow) {
$backupcourse->nextstarttime = $nextstarttime;
$DB->update_record('backup_courses', $backupcourse);
mtrace('Skipping ' . $course->fullname . ' (Not scheduled for backup until ' . $showtime . ')');
} else if ($skipped) { // Must have been skipped for a reason.
$backupcourse->laststatus = self::BACKUP_STATUS_SKIPPED;
$backupcourse->nextstarttime = $nextstarttime;
$DB->update_record('backup_courses', $backupcourse);
mtrace('Skipping '.$course->fullname.' ('.$skippedmessage.')');
mtrace('Skipping ' . $course->fullname . ' (' . $skippedmessage . ')');
mtrace('Backup of \'' . $course->fullname . '\' is scheduled on ' . $showtime);
} else {
// Backup every non-skipped courses.
mtrace('Backing up '.$course->fullname.'...');
Expand Down

0 comments on commit 8580fba

Please sign in to comment.