Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
Utility helper for automated backups run through cron.
Copyright: | 2010 Sam Hemelryk |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 799 lines (33 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
backup_cron_automated_helper:: (17 methods):
get_courses()
run_automated_backup()
get_backup_status_array()
send_backup_status_to_admin()
check_and_push_automated_backups()
should_skip_course_backup()
push_course_backup_adhoc_task()
calculate_next_automated_backup()
launch_automated_backup()
outcome_from_results()
remove_deleted_courses_from_schedule()
get_automated_backup_lock()
remove_excess_backups()
remove_excess_backups_from_course()
remove_excess_backups_from_directory()
get_backups_to_delete()
is_course_modified()
Class: backup_cron_automated_helper - X-Ref
This class is an abstract class with methods that can be called to aid theget_courses($now = null) X-Ref |
Get the courses to backup. When there are multiple courses to backup enforce some order to the record set. The following is the preference order. First backup courses that do not have an entry in backup_courses first, as they are likely new and never been backed up. Do the oldest modified courses first. Then backup courses that have previously been backed up starting with the oldest next start time. Finally, all else being equal, defer to the sortorder of the courses. return: moodle_recordset The recordset of matching courses. param: null|int $now timestamp to use in course selection. |
run_automated_backup($rundirective = self::RUN_ON_SCHEDULE) X-Ref |
Runs the automated backups if required param: bool $rundirective |
get_backup_status_array() X-Ref |
Gets the results from the last automated backup that was run based upon the statuses of the courses that were looked at. return: array |
send_backup_status_to_admin($admin) X-Ref |
Collect details for all statuses of the courses and send report to admin. return: array param: stdClass $admin |
check_and_push_automated_backups($courses, $admin) X-Ref |
Loop through courses and push to course ad-hoc task if required return: boolean param: \record_set $courses param: stdClass $admin |
should_skip_course_backup($backupcourse, $course, $nextstarttime) X-Ref |
Check if we can skip this course backup. return: boolean param: stdClass $backupcourse param: stdClass $course param: int $nextstarttime |
push_course_backup_adhoc_task($backupcourse, $admin) X-Ref |
Create course backup adhoc task return: void param: stdClass $backupcourse param: stdClass $admin |
calculate_next_automated_backup($ignoredtimezone, $now) X-Ref |
Works out the next time the automated backup should be run. return: int timestamp of the next execution at server time param: mixed $ignoredtimezone all settings are in server timezone! param: int $now timestamp, should not be in the past, most likely time() |
launch_automated_backup($course, $starttime, $userid) X-Ref |
Launches a automated backup routine for the given course return: bool param: stdClass $course param: int $starttime param: int $userid |
outcome_from_results($results) X-Ref |
Returns the backup outcome by analysing its results. return: int {@link self::BACKUP_STATUS_OK} and other constants param: array $results returned by a backup |
remove_deleted_courses_from_schedule() X-Ref |
Removes deleted courses fromn the backup_courses table so that we don't waste time backing them up. return: int |
get_automated_backup_lock($rundirective = self::RUN_ON_SCHEDULE) X-Ref |
Try to get lock for automated backup. return: \core\lock\lock|boolean - An instance of \core\lock\lock if the lock was obtained, or false. param: int $rundirective |
remove_excess_backups($course, $now = null) X-Ref |
Removes excess backups from a specified course. return: bool Whether or not backups is being removed param: stdClass $course Course object param: int $now Starting time of the process |
remove_excess_backups_from_course($course, $now) X-Ref |
Removes excess backups in the course backup filearea from a specified course. return: bool Whether or not backups are being removed param: stdClass $course Course object param: int $now Starting time of the process |
remove_excess_backups_from_directory($course, $now) X-Ref |
Removes excess backups in the specified external directory from a specified course. return: bool Whether or not backups are being removed param: stdClass $course Course object param: int $now Starting time of the process |
get_backups_to_delete($backupfiles, $now) X-Ref |
Get the list of backup files to delete depending on the automated backup settings. return: array Backup files to delete param: array $backupfiles Existing backup files param: int $now Starting time of the process |
is_course_modified($courseid, $since) X-Ref |
Check logs to find out if a course was modified since the given time. return: bool true if the course was modified, false otherwise. This also returns false if no readers are enabled. This is param: int $courseid course id to check param: int $since timestamp, from which to check |