Automated course backup
Automating course backups
Automated course backups runs the same functions as individual course backups. It's a good idea to schedule backups for when your server isn't usually busy. Running the backup tool over all the courses can be processor-intensive, so you shouldn't run it when there are a lot of students trying to access the server. You should always alert users with an announcement on the first page that if they log on during the backup hours they may notice a decrease in performance.
In order to make scheduled backups, you have to set up CRON to run periodically. Please refer to the cron instructions.
Setting an automated course backup schedule
To set the backup schedule:
- Go to Administration > Site administration > Courses > Backups > Automated backup setup.
- Set backup_auto_active to enabled.
- Select the days of the week to run the backup.
- Set the execution time for the backup process. For most servers, early morning will be the best time. Keep in mind the time zone your server is using.
- Set the "Save to..." path. If you can, choose a backup path on another machine or on a different drive than the one Moodle is on. You don’t want to lose your backups at the same time you lose your Moodle site if the drive fails. If you leave the field blank, then backup zip files will be saved in the backup folder of each course files folder. On a Linux server the path might look like: /home/(your user or domain)/public_html/archive/ or if it's below the publicly accessible folders: /home/(your user or domain)/archive/ if the path is not recognized a red X is shown after saving, otherwise a green check.
- Set all other options appropriately.
- Click the "Save changes" button.
Tip: To save disk space, you can choose to delete backups older than a specified number of days. If so, you should also specify a minimum number of backups to be kept. (The settings 'Delete backups older than' and 'Minimum number of backups kept' are new in Moodle 3.0 onwards.)
Once you've set up your backup schedule, Moodle will automatically create archives of all the courses on the server at the time you specified. Once the backup is complete, Moodle will send you an email describing the status of the backup.
A last execution log of scheduled course backups can be found in Administration > Site administration > Reports > Backups. It displays a list of all course backups made, the time taken to create them, their status (see below), and the next scheduled automated backup execution time.
Clicking the 'View logs' icon next to the course name (1 in screenshot below) will display a detailed backup log for a particular course, including date, hour and minute when each step of the backup was performed (2). This log is useful for troubleshooting backup errors.
- OK - The course backup was successfully completed.
- Skipped - The course was skipped (not backed up) because the course was unavailable to students and had not been changed in the last 31 days. This is not an error, but a feature designed to save process time.
- Unfinished - The backup was not finished. This might have happened because the job to execute backups ran out of time or resources (e.g., the cron running the backups ran out of time before finishing all the courses waiting). The unfinished jobs should be completed when the next scheduled backups are repeated.
- Error - There were errors in the backup process for the course, so a backup was not completed. For additional details about the error (1) check the backup log for the affected course (i.e. click the 'View logs' icon next to the course name) or (2) back up the course manually with debugging turned on to see what error message is displayed.
Course versus site backups
- Automated course backups are more expensive in terms of time and CPU usage. The recovery time to have your site running again is longer.
- Course backups are useful for obtaining "fresh" copies of courses to be re-used or distributed individually, however they should never be used as a primary backup system (unless your hosting doesn't allow the preferred site backups).
Both the download course backup files capability and the restore user data from a course backup capability are required to be able to download automated course backups. There is also a restore courses from the automated backup storage capability.