Note: You are currently viewing documentation for Moodle 3.9. Up-to-date documentation for the latest stable version of Moodle may be available here: Course backup.

Course backup: Difference between revisions

From MoodleDocs
(→‎Asynchronous course backups: updated setting location)
 
(40 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Backup}}
{{Backup}}
A course can be saved with some or all of its parts by using the course backup.  Typically, the site administrator will set a schedule of [[Automated course backup|automated course backups]] for the whole site.  A teacher with editing privileges can create a backup or download an existing backup for safe keeping, or for use on another Moodle site.   
A course can be saved with some or all of its parts by using the course backup.  Typically, the site administrator will set a schedule of [[Automated course backup|automated course backups]] for the whole site.  A teacher can create a backup or download an existing backup for safe keeping, or for use on another Moodle site.   
 
{{MediaPlayer | url = https://youtu.be/eNe6kRv2ndI| desc = Course backup: Moodle 3.7}}
 


==Backing up a course==
==Backing up a course==
Line 6: Line 9:
To backup a course
To backup a course


* Go to ''Administration > Course administration > Backup''
# Go into the course.
* Initial settings - Select activities, blocks, filters and other items as required then click the Next button. Users with appropriate permissions, such as administrators and managers, can choose whether to [[Backup of user data|include users]], anonymize user information, or include user role assignments, user files, comments, user completion details, course logs and grade history in the backup.
# Click the Backup link either in the gear menu or the Administration block (depending upon the theme).
* Schema settings  - Select/deselect specific items to include in backup, then click the Next button.
# Initial settings - Select activities, blocks, filters and other items as required then click the Next button. Users with appropriate permissions, such as administrators and managers, can choose whether to [[Backup of user data|include users]], anonymize user information, or include user role assignments, groups, groupings, user files, comments, user completion details, course logs and grade history in the backup.
 
# Schema settings  - Select/deselect specific items to include in backup, then click the Next button.
* If desired, select specific types of activity to be backed up by clicking the link 'Show type options' {{New features}}
# If desired, select specific types of activity to be backed up by clicking the link 'Show type options'  
# Confirmation and review - Check that everything is as required, using the Previous button if necessary, otherwise click the 'Perform backup' button
# Complete - Click the Continue button


{|
{|
[[File:backupgroups.png|thumb|Backup settings]]
|
|[[File:26backuprestore1.png|thumb|Back up screen with option to select all or none]]
|[[File:26backuprestore1.png|thumb|Back up screen with option to select all or none]]
|
|
Line 18: Line 25:
|}
|}


* Confirmation and review - Check that everything is as required, using the Previous button if necessary, otherwise click the 'Perform backup' button
A backup file (with distinctive .mbz extension to avoid confusion with .zip files) is then saved in the course backup area. Backup file names are of the form ''backup-moodle2-course-coursename-date-hour.mbz'', ending in ''-nu.mbz'' when backed up with no users and ''-an.mbz''  with anonymized names.
* Complete - Click the Continue button


A backup file (with distinctive .mbz extension to avoid confusion with .zip files) is then saved in the course backup area.
Tip: If you are satisfied with the default settings and don't wish to go through all the backup screens, you can simply click 'Jump to final step' to perform the backup.


==Anonymizing user information==
==Anonymizing user information==
Line 27: Line 33:
Anonymize user information is a backup feature which "protects user identities" by making each user anonymous. If this box is checked in the backup initial settings, Moodle will substitute aliases for real names, substituting @doesntexist.com email addresses and so forth. For example  "Max Manager" might become  "anonfirstname4 anonlastname4".
Anonymize user information is a backup feature which "protects user identities" by making each user anonymous. If this box is checked in the backup initial settings, Moodle will substitute aliases for real names, substituting @doesntexist.com email addresses and so forth. For example  "Max Manager" might become  "anonfirstname4 anonlastname4".


==Backup and restore from 1.9 to 2==
==Asynchronous course backups==
 
Note: With large courses it is helpful to be able to continue working while a course backup is being made. To achieve this, you need to enable asynchronous backups in ''Site Administration / Courses / Backups / Asynchronous backup/restore''.
 
==Backup via CLI for administrators==
 
Site administrators can backup selected courses using a CLI script.
 
===Options===
* --courseid=INTEGER (Course ID for backup.)
* --courseshortname=STRING (Course shortname for backup.)
* --destination=STRING (Path where to store backup file. If not set the backup will be stored within the course backup file area.)
* -h, --help (Print out this help.)
 
===Example===
<code php>
\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/
</code>
 
On Windows you will use cmd.exe to run the /admin/cli/backup.php script. If you have your Moodledata folder setup on a separate data server you can specify a UNC path to your backup folder on that data server. From the command line CD to the Moodle ''\admin\cli'' folder and run this command:
<code php>
php backup.php --courseid=25 --destination=\\moodledata\backup
</code>


Courses created in 1.9 can be backed up and then restored into a 2.1 Moodle or later but blocks are not currently restored and nor is user data (such as forum posts, grades, submissions etc)
where '--courseid' is the id of the course that you want to backup.
 
The .mbz backup file for courseid=25 will be stored in the ''backup'' subfolder in the ''Moodledata'' ($CFG->dataroot) folder.


==Tips and tricks==
==Tips and tricks==
Line 44: Line 74:
==General backup defaults==
==General backup defaults==


Default settings for course backups can be set by a site administrator in ''Settings > Site administration > Courses > Backups > General backup defaults''.
Default settings for course backups can be set by a site administrator in 'General backup defaults' in the Site administration.


Selected settings may be locked, so that they cannot be changed when creating a course backup.
Selected settings may be locked, so that they cannot be changed when creating a course backup.


By selecting a time in the "Keep logs for.."  dropdown, it is possible to specify how long backup  logs information is kept before being deleted. As this information may be very large, it is recommended the length of time chosen be quite short.
By selecting a time in the "Keep logs for.."  dropdown, it is possible to specify how long backup  logs information is kept before being deleted. As this information may be very large, it is recommended the length of time chosen be quite short.
==Course backup stops above 90%, not showing any errors==
This has been reported to be caused by:
* a [[Course_formats#Contributed_Course_Formats|non-standard course_format]]. Try replacing the course format.
* not enough server RAM. Adding more RAM to your server is usually the first [[Performance_recommendations|performance recomendation]].


==Course backup capabilities==
==Course backup capabilities==
Line 55: Line 90:
*[[Capabilities/moodle/backup:backupcourse|Backup courses]]
*[[Capabilities/moodle/backup:backupcourse|Backup courses]]
*[[Capabilities/moodle/backup:backupsection|Backup sections]]
*[[Capabilities/moodle/backup:backupsection|Backup sections]]
*[[Capabilities/moodle/backup:backuptargethub|Backup for hub]]
*[[Capabilities/moodle/backup:backuptargetimport|Backup for import]]
*[[Capabilities/moodle/backup:backuptargetimport|Backup for import]]
*[[Capabilities/moodle/backup:configure|Configure backup options]]
*[[Capabilities/moodle/backup:configure|Configure backup options]]
*[[Capabilities/moodle/backup:downloadfile|Download files from backup areas]]
*[[Capabilities/moodle/backup:downloadfile|Download files from backup areas]]
*[[Capabilities/moodle/backup:userinfo|Backup user data]]
*[[Capabilities/moodle/backup:userinfo|Backup user data]]
==Error: Trying to restore user 'admin' from backup file will cause conflict ==
* Before proceeding, it would be advisable to have a second admin account ''just in case something goes wrong''.
* Check that the admin accounts on each server have '''different''' unique usernames and email addresses and then try again to backup up the course with user data and restore it.
** If you can not make a new backup and you must use an existing 'conflicting' backup file, you will have to change the new site's main admin account with extreme care to remember the new main admin's password and email.
* Note that the admin account from the imported file may loose the password and become unusable;
* You are advised to update/reset the 'imported' main 'admin's account's password before logging out, as this will most likely be the main 'admin' account for the site, and you would get into serious problems if this account stops working.
* If something goes terribly wrong, you can use the second admin account to fix the main admin account.


==See also==
==See also==
Line 66: Line 108:
*[[Backup of user data]]
*[[Backup of user data]]
*[[Activity backup]]
*[[Activity backup]]
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI
[[Category:Course]]


[[de:Kurssicherung]]
[[de:Kurssicherung]]

Latest revision as of 08:38, 25 June 2020

A course can be saved with some or all of its parts by using the course backup. Typically, the site administrator will set a schedule of automated course backups for the whole site. A teacher can create a backup or download an existing backup for safe keeping, or for use on another Moodle site.

Course backup: Moodle 3.7


Backing up a course

To backup a course

  1. Go into the course.
  2. Click the Backup link either in the gear menu or the Administration block (depending upon the theme).
  3. Initial settings - Select activities, blocks, filters and other items as required then click the Next button. Users with appropriate permissions, such as administrators and managers, can choose whether to include users, anonymize user information, or include user role assignments, groups, groupings, user files, comments, user completion details, course logs and grade history in the backup.
  4. Schema settings - Select/deselect specific items to include in backup, then click the Next button.
  5. If desired, select specific types of activity to be backed up by clicking the link 'Show type options'
  6. Confirmation and review - Check that everything is as required, using the Previous button if necessary, otherwise click the 'Perform backup' button
  7. Complete - Click the Continue button
Backup settings
Back up screen with option to select all or none
Back up screen with option to select activity types

A backup file (with distinctive .mbz extension to avoid confusion with .zip files) is then saved in the course backup area. Backup file names are of the form backup-moodle2-course-coursename-date-hour.mbz, ending in -nu.mbz when backed up with no users and -an.mbz with anonymized names.

Tip: If you are satisfied with the default settings and don't wish to go through all the backup screens, you can simply click 'Jump to final step' to perform the backup.

Anonymizing user information

Anonymize user information is a backup feature which "protects user identities" by making each user anonymous. If this box is checked in the backup initial settings, Moodle will substitute aliases for real names, substituting @doesntexist.com email addresses and so forth. For example "Max Manager" might become "anonfirstname4 anonlastname4".

Asynchronous course backups

Note: With large courses it is helpful to be able to continue working while a course backup is being made. To achieve this, you need to enable asynchronous backups in Site Administration / Courses / Backups / Asynchronous backup/restore.

Backup via CLI for administrators

Site administrators can backup selected courses using a CLI script.

Options

  • --courseid=INTEGER (Course ID for backup.)
  • --courseshortname=STRING (Course shortname for backup.)
  • --destination=STRING (Path where to store backup file. If not set the backup will be stored within the course backup file area.)
  • -h, --help (Print out this help.)

Example

\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/

On Windows you will use cmd.exe to run the /admin/cli/backup.php script. If you have your Moodledata folder setup on a separate data server you can specify a UNC path to your backup folder on that data server. From the command line CD to the Moodle \admin\cli folder and run this command: php backup.php --courseid=25 --destination=\\moodledata\backup

where '--courseid' is the id of the course that you want to backup.

The .mbz backup file for courseid=25 will be stored in the backup subfolder in the Moodledata ($CFG->dataroot) folder.

Tips and tricks

  • Lose content after a restore in Moodle 2.0 ? Do you see topic headings that say "Orphaned activities"? Solution: Go to course settings and increase the number of topic sections and things will return to normal.

Creative uses

The backup and restore processes can offer the teacher and administrators many creative solutions.

  • Duplicating courses or specific activities in one course to another course (similar to Import)
  • Updating a production Moodle site course, with material from a localhost site course
  • Transferring a course to a new Moodle site.
  • In earlier versions of Moodle, a way of rolling a course forward without past student activity
  • Creating a blank activity, save just that activity and then restore it to the course or another course one or more times.

General backup defaults

Default settings for course backups can be set by a site administrator in 'General backup defaults' in the Site administration.

Selected settings may be locked, so that they cannot be changed when creating a course backup.

By selecting a time in the "Keep logs for.." dropdown, it is possible to specify how long backup logs information is kept before being deleted. As this information may be very large, it is recommended the length of time chosen be quite short.

Course backup stops above 90%, not showing any errors

This has been reported to be caused by:

Course backup capabilities

Error: Trying to restore user 'admin' from backup file will cause conflict

  • Before proceeding, it would be advisable to have a second admin account just in case something goes wrong.
  • Check that the admin accounts on each server have different unique usernames and email addresses and then try again to backup up the course with user data and restore it.
    • If you can not make a new backup and you must use an existing 'conflicting' backup file, you will have to change the new site's main admin account with extreme care to remember the new main admin's password and email.
  • Note that the admin account from the imported file may loose the password and become unusable;
  • You are advised to update/reset the 'imported' main 'admin's account's password before logging out, as this will most likely be the main 'admin' account for the site, and you would get into serious problems if this account stops working.
  • If something goes terribly wrong, you can use the second admin account to fix the main admin account.

See also