mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-42201 backup: introduced new automatic backup state
This commit is contained in:
parent
4e47920f08
commit
70f210c04f
@ -32,11 +32,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
abstract class backup_cron_automated_helper {
|
||||
|
||||
/** automated backups are active and ready to run */
|
||||
/** Automated backups are active and ready to run */
|
||||
const STATE_OK = 0;
|
||||
/** automated backups are disabled and will not be run */
|
||||
/** Automated backups are disabled and will not be run */
|
||||
const STATE_DISABLED = 1;
|
||||
/** automated backups are all ready running! */
|
||||
/** Automated backups are all ready running! */
|
||||
const STATE_RUNNING = 2;
|
||||
|
||||
/** Course automated backup completed successfully */
|
||||
@ -49,6 +49,8 @@ abstract class backup_cron_automated_helper {
|
||||
const BACKUP_STATUS_SKIPPED = 3;
|
||||
/** Course automated backup had warnings */
|
||||
const BACKUP_STATUS_WARNING = 4;
|
||||
/** Course automated backup has yet to be run */
|
||||
const BACKUP_STATUS_NOTYETRUN = 5;
|
||||
|
||||
/** Run if required by the schedule set in config. Default. **/
|
||||
const RUN_ON_SCHEDULE = 0;
|
||||
@ -120,12 +122,13 @@ abstract class backup_cron_automated_helper {
|
||||
|
||||
$rs = $DB->get_recordset('course');
|
||||
foreach ($rs as $course) {
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid'=>$course->id));
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid' => $course->id));
|
||||
if (!$backupcourse) {
|
||||
$backupcourse = new stdClass;
|
||||
$backupcourse->courseid = $course->id;
|
||||
$DB->insert_record('backup_courses',$backupcourse);
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid'=>$course->id));
|
||||
$backupcourse->laststatus = self::BACKUP_STATUS_NOTYETRUN;
|
||||
$DB->insert_record('backup_courses', $backupcourse);
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid' => $course->id));
|
||||
}
|
||||
|
||||
// The last backup is considered as successful when OK or SKIPPED.
|
||||
@ -229,16 +232,17 @@ abstract class backup_cron_automated_helper {
|
||||
$count = backup_cron_automated_helper::get_backup_status_array();
|
||||
$haserrors = ($count[self::BACKUP_STATUS_ERROR] != 0 || $count[self::BACKUP_STATUS_UNFINISHED] != 0);
|
||||
|
||||
//Build the message text
|
||||
//Summary
|
||||
$message .= get_string('summary')."\n";
|
||||
// Build the message text.
|
||||
// Summary.
|
||||
$message .= get_string('summary') . "\n";
|
||||
$message .= "==================================================\n";
|
||||
$message .= " ".get_string('courses').": ".array_sum($count)."\n";
|
||||
$message .= " ".get_string('ok').": ".$count[self::BACKUP_STATUS_OK]."\n";
|
||||
$message .= " ".get_string('skipped').": ".$count[self::BACKUP_STATUS_SKIPPED]."\n";
|
||||
$message .= " ".get_string('error').": ".$count[self::BACKUP_STATUS_ERROR]."\n";
|
||||
$message .= " ".get_string('unfinished').": ".$count[self::BACKUP_STATUS_UNFINISHED]."\n";
|
||||
$message .= " ".get_string('warning').": ".$count[self::BACKUP_STATUS_WARNING]."\n\n";
|
||||
$message .= ' ' . get_string('courses') . '; ' . array_sum($count) . "\n";
|
||||
$message .= ' ' . get_string('ok') . '; ' . $count[self::BACKUP_STATUS_OK] . "\n";
|
||||
$message .= ' ' . get_string('skipped') . '; ' . $count[self::BACKUP_STATUS_SKIPPED] . "\n";
|
||||
$message .= ' ' . get_string('error') . '; ' . $count[self::BACKUP_STATUS_ERROR] . "\n";
|
||||
$message .= ' ' . get_string('unfinished') . '; ' . $count[self::BACKUP_STATUS_UNFINISHED] . "\n";
|
||||
$message .= ' ' . get_string('warning') . '; ' . $count[self::BACKUP_STATUS_WARNING] . "\n";
|
||||
$message .= ' ' . get_string('backupnotyetrun') . '; ' . $count[self::BACKUP_STATUS_NOTYETRUN]."\n\n";
|
||||
|
||||
//Reference
|
||||
if ($haserrors) {
|
||||
@ -301,7 +305,8 @@ abstract class backup_cron_automated_helper {
|
||||
self::BACKUP_STATUS_OK => 0,
|
||||
self::BACKUP_STATUS_UNFINISHED => 0,
|
||||
self::BACKUP_STATUS_SKIPPED => 0,
|
||||
self::BACKUP_STATUS_WARNING => 0
|
||||
self::BACKUP_STATUS_WARNING => 0,
|
||||
self::BACKUP_STATUS_NOTYETRUN => 0
|
||||
);
|
||||
|
||||
$statuses = $DB->get_records_sql('SELECT DISTINCT bc.laststatus, COUNT(bc.courseid) AS statuscount FROM {backup_courses} bc GROUP BY bc.laststatus');
|
||||
|
@ -188,6 +188,7 @@ $string['backuploglaststatus'] = 'Last execution log';
|
||||
$string['backupmissinguserinfoperms'] = 'Note: This backup contains no user data. Exercise and Workshop activities will not be included in the backup, since these modules are not compatible with this type of backup.';
|
||||
$string['backupnext'] = 'Next backup';
|
||||
$string['backupnonisowarning'] = 'Warning: this backup is from a non-Unicode version of Moodle (pre 1.6). If this backup contains any non-ISO-8859-1 texts then they may be CORRUPTED if you try to restore them to this Unicode version of Moodle. See the <a href="http://docs.moodle.org/en/Backup_FAQ">Backup FAQ</a> for more information about how to recover this backup correctly.';
|
||||
$string['backupnotyetrun'] = 'Automated backup pending';
|
||||
$string['backuporiginalname'] = 'Backup name';
|
||||
$string['backuproleassignments'] = 'Backup role assignments for these roles';
|
||||
$string['backupsavetohelp'] = 'Full path to the directory where you want to save the backup files<br />(leave blank to save in its course default dir)';
|
||||
|
@ -2511,7 +2511,7 @@
|
||||
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="laststarttime" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="lastendtime" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="laststatus" TYPE="char" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="laststatus" TYPE="char" LENGTH="1" NOTNULL="true" DEFAULT="5" SEQUENCE="false"/>
|
||||
<FIELD NAME="nextstarttime" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
|
@ -2689,5 +2689,17 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2013100901.00);
|
||||
}
|
||||
|
||||
if ($oldversion < 2013102100.00) {
|
||||
// Changing default value for the status of a course backup.
|
||||
$table = new xmldb_table('backup_courses');
|
||||
$field = new xmldb_field('laststatus', XMLDB_TYPE_CHAR, '1', null, XMLDB_NOTNULL, null, '5', 'lastendtime');
|
||||
|
||||
// Launch change of precision for field value
|
||||
$dbman->change_field_precision($table, $field);
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2013102100.00);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -42,12 +42,13 @@ $table->headspan = array(1, 3, 1, 1);
|
||||
$table->attributes = array('class' => 'generaltable backup-report');
|
||||
$table->data = array();
|
||||
|
||||
$strftimedatetime = get_string("strftimerecent");
|
||||
$strerror = get_string("error");
|
||||
$strok = get_string("ok");
|
||||
$strunfinished = get_string("unfinished");
|
||||
$strskipped = get_string("skipped");
|
||||
$strwarning = get_string("warning");
|
||||
$strftimedatetime = get_string('strftimerecent');
|
||||
$strerror = get_string('error');
|
||||
$strok = get_string('ok');
|
||||
$strunfinished = get_string('unfinished');
|
||||
$strskipped = get_string('skipped');
|
||||
$strwarning = get_string('warning');
|
||||
$strnotyetrun = get_string('backupnotyetrun');
|
||||
|
||||
$select = ', ' . context_helper::get_preload_record_columns_sql('ctx');
|
||||
$join = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
|
||||
@ -61,22 +62,25 @@ foreach ($rs as $backuprow) {
|
||||
// Cache the course context
|
||||
context_helper::preload_from_record($backuprow);
|
||||
|
||||
// Prepare a cell to display the status of the entry
|
||||
// Prepare a cell to display the status of the entry.
|
||||
if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_OK) {
|
||||
$status = $strok;
|
||||
$statusclass = 'backup-ok'; // Green
|
||||
$statusclass = 'backup-ok'; // Green.
|
||||
} else if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_UNFINISHED) {
|
||||
$status = $strunfinished;
|
||||
$statusclass = 'backup-unfinished'; // Red
|
||||
$statusclass = 'backup-unfinished'; // Red.
|
||||
} else if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_SKIPPED) {
|
||||
$status = $strskipped;
|
||||
$statusclass = 'backup-skipped'; // Green
|
||||
$statusclass = 'backup-skipped'; // Green.
|
||||
} else if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_WARNING) {
|
||||
$status = $strwarning;
|
||||
$statusclass = 'backup-warning'; // Orange
|
||||
$statusclass = 'backup-warning'; // Orange.
|
||||
} else if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_NOTYETRUN) {
|
||||
$status = $strnotyetrun;
|
||||
$statusclass = 'backup-notyetrun';
|
||||
} else {
|
||||
$status = $strerror;
|
||||
$statusclass = 'backup-error'; // Red
|
||||
$statusclass = 'backup-error'; // Red.
|
||||
}
|
||||
$status = new html_table_cell($status);
|
||||
$status->attributes = array('class' => $statusclass);
|
||||
|
@ -90,6 +90,7 @@
|
||||
#page-admin-report-backups-index .backup-skipped,
|
||||
#page-admin-report-backups-index .backup-ok {color: #006400;}
|
||||
#page-admin-report-backups-index .backup-warning {color: #ff9900;}
|
||||
#page-admin-report-backups-index .backup-notyetrun {color: #006400;}
|
||||
|
||||
#page-admin-qbehaviours .disabled {color: gray;}
|
||||
#page-admin-qbehaviours th {white-space: normal;}
|
||||
|
@ -93,7 +93,8 @@
|
||||
}
|
||||
|
||||
#page-admin-report-backups-index .backup-skipped,
|
||||
#page-admin-report-backups-index .backup-ok {
|
||||
#page-admin-report-backups-index .backup-ok,
|
||||
#page-admin-report-backups-index .backup-notyetrun {
|
||||
color: @successText;
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -29,11 +29,10 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2013101800.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2013102100.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
$release = '2.6beta (Build: 20131018)'; // Human-friendly version name
|
||||
|
||||
$release = '2.6beta (Build: 20131021)'; // Human-friendly version name
|
||||
$branch = '26'; // This version's branch.
|
||||
$maturity = MATURITY_BETA; // This version's maturity level.
|
||||
|
Loading…
x
Reference in New Issue
Block a user