Permalink
Browse files

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

…o MOODLE_24_STABLE
  • Loading branch information...
2 parents 945aa97 + 6c2d913 commit d9131593c7d8588059bb60db857a7420dd6bdcc6 @stronk7 stronk7 committed Oct 13, 2013
Showing with 18 additions and 13 deletions.
  1. +18 −13 backup/util/helper/backup_cron_helper.class.php
@@ -132,19 +132,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.
@@ -159,7 +163,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,
@@ -170,16 +174,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 d913159

Please sign in to comment.