Details
Description
Currently the backup system tends to ignore errors return values. It calls lots of functions, which may return false, but does not always take action as a result of the return value.
For 2.0 HEAD, we would like to change it as follows:
1) When any function called during backup returns false, an error should be printed at that point. The error should make clear which activity or part of the data caused the error, so that [for example] the user could retry the backup without that activity.
2) The system should continue with the backup as at present, but track whether an error occurred. At the end of a backup a clear message should display ('Backup completed succesfully' or 'Backup completed with errors').
3) Depending on a config option, admins can set up the system so that when a backup has errors, it is aborted. (The abort would happen either at the point where the error occurs, or at the final stage, to be determined. But either way it wouldn't make the zip file.) This would be an option because sometimes there are backup problems that are not fatal and, for sites that don't have a development team, a partial backup is better than none.
4) This config option should be configurable in the admin pages in the same place as any existing backup-related options.
5) Moodle has a system for running scheduled backups. When a scheduled backup is running, this should always be continued (not aborted) even if errors occur, regardless of the config option.
I just checked with sam to get a little more detail. Here is what he explained
an example is function backup_module (line 2278 in backuplib.php in current MOODLE_19).
foreach ($preferences->mods[$module]->instances as $instance => $object) {
if (!empty($object->backup)) { $status = $onemodbackup($bf,$preferences,$instance); }
}
As you can see, this will set the final 'status' value to whatever the last module returned. So if modules 1, 2, 3, and 4 fail, but module 5 passes, this function returns success. This is clearly wrong. In addition, this function also does not output any status information - which should be visible always-displayed status information, not just
debugging() - indicating which module instance has actually failed.
The way this was written (status value getting overwritten, not displaying information about which module caused a failure) appeared to me to be endemic across backup/restore code - that's what I wanted sorting out.