Skip to content
Browse files

Merge branch 'MDL-37181_m25' of https://github.com/markn86/moodle int…

…o MOODLE_25_STABLE
  • Loading branch information...
2 parents 5c74090 + 8580fba commit 2f334c64645cb624f0d242b04fa9495c6b2d9358 @stronk7 stronk7 committed Oct 13, 2013
Showing with 18 additions and 13 deletions.
  1. +18 −13 backup/util/helper/backup_cron_helper.class.php
View
31 backup/util/helper/backup_cron_helper.class.php
@@ -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.
@@ -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,
@@ -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.'...');

0 comments on commit 2f334c6

Please sign in to comment.
Something went wrong with that request. Please try again.