-

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

Course restore: Difference between revisions

From MoodleDocs
(note re backup 2.0)
(updated video)
 
(41 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Course admin}}<p class="note">'''Note:''' Course backup and restore has been completely rewritten for Moodle 2.0. See [[Backup 2.0]] for details.</p>
{{Backup}}
==Restoring a course backup==


A course backup file (.mbz) may be restored from within any existing course for which you have permission. During the restore process, you will be given the option to restore as a new course or into an existing course.


Courses can be restored from a backup made by Moodle.  Course backups are usually stored in the '''backupdata''' folder within the [[Files|course files]] folder. There is a restore link next to every course backup.
{{MediaPlayer | url = https://youtu.be/mnZJvn3bAyE | desc = Overview of course restore. (Instructions are for MoodleCloud but also apply to other sites.)}}


The backup and restore process is a common way of moving or, copying specific courses from one Moodle to another.
# With the [[Boost theme]] click the gear menu and then 'Restore' Otherwise, go to ''Site administration > Front page settings > Restore'' (if you have front page permissions) or ''Administration > Course administration > Restore'' (if you have an empty course to restore into.)
# Upload the backup file or choose a file in the course backup area or user private backup area and click Restore
# Confirm - Check that everything is as required then click the Continue button
# Destination - Choose whether the course should be restored as a new course or into an existing course then click the Continue button
# Settings - Select activities, blocks, filters and possibly other items as required then click the Next button
# Schema - Select/deselect specific items and amend the course name, short name and start date if necessary then click the Next button
# Review - Check that everything is as required, using the Previous button if necessary, then click the 'Perform restore' button
# Complete - Click the continue button


Notes:


==Restoring a course==
# If you are restoring a course with user data (forum posts for example) then  the user data will keep the original dates, whereas the activities and sections will change according to the new course start time you set.
[[Image:Course_restore_s1.jpg|thumb|The backupdata folder]][[Image:Course_restore_s1b.jpg|thumb|Restoring a course - page 1]][[Image:Course_restore_s2.jpg|thumb|Restoring a course - page 2]][[Image:Course_restore_s3.jpg|thumb|Restoring a course - page 3]]
# If your new course has fewer sections than the course you are restoring, the extra sections will appear as "orphaned activities". Increase the number of sections in the new course to make them visible.
To restore a course from a backup file:
# If you are restoring a course from a different Moodle site and you obtain the error message "Trying to restore user (admin) from backup file will cause conflict", you can enable the setting 'Allow admin conflict resolution' in ''Site admin > Courses > Backups > General import defaults''
# When restoring a course containing calendar events from activities e.g. assignment due dates, these events will appear in the calendar a short while after restoring the course. The events are added to the calendar via a cron task. Restoring multiple courses will result in queued tasks with a possible delay before events appear in the calendar.


#Either upload a backup zip file to your course files area or click Restore in the [[Course administration block]] to access the backupdata folder.
==Restoring from course and category management screens==
#Click the Restore link opposite the file you want to restore.
#On the next page, click Yes to the question "Do you want to continue?" to start the restore process.
#Click the Continue button at the bottom of the next page, listing details of the backup.
#On the next page, select whether you want to restore to the existing course, adding data to it or deleting it first. If you have permission to restore to a new course, the restore page will contain additional options for setting the new course category, short name, full name, and start date.
#Choose which activities you want to restore and whether to include user data (option only available for users with the capability [[Capabilities/moodle/restore:userinfo|moodle/restore:userinfo]]).
#Select course users if you are including user data (option only available for users with the capability [[Capabilities/moodle/restore:userinfo|moodle/restore:userinfo]]).
#Select appropriate role mappings. The options depend upon the roles you are allowed to assign. By default, teachers are only allowed to assign the roles of non-editing teacher, student, and guest.
#Click the Continue button.
#On the next page, click the "Restore this course now!" button.
#On the next page, the progress of the restore is displayed with a report if it was successful. Click the Continue button.


Restoring a course from a back-up file saved on a local computer:
Users with permission to access ''Site administration > Courses > Manage courses and categories'' or ''Site administration > Courses > Manage courses and categories > (Category name)'' can restore courses from here:
In case you are restoring a course to a new site, please remember to check the course category after restoration. Courses get restored in the default category and you might have to manually move it to the correct category.


''Note'': In Moodle 1.8.11 and 1.9.7 onwards, hashed user passwords are no longer saved in backup files containing user data. If a backup is restored to a new site, users will be asked to go through the "forgot my password" routine the first time they log in.
{|
| [[File:RestoreBoost.png|thumb|400px|Boost theme]]
| [[File:courserestorecategory.png|thumb|200px|Non-Boost themes]]
|}


==Role mappings==
==General restore defaults==
The procedure of restoring a 1.6 or older course to a 1.7 site requires additional role mapping information to be entered (on page 3). Since Moodle 1.7 has a dynamic roles system, it is possible to map the old roles (i.e. editing teachers, non-editing teachers and students) onto any new roles. By default, Moodle 1.7 looks for legacy roles to map intelligently, for example students in 1.6 are mapped onto the 1.7 legacy student role.


When restoring a 1.7 course to a 1.7 site, Moodle compares the role shortname string and pre-selects the same for you. As a result, if you are restoring within the same site, you don't have to worry about selecting what roles to map onto.
An administrator can set defaults and lock selected restore settings in 'General restore defaults' in the Site administration. If a setting is locked, then it can not be changed when restoring a course.


Role options are determined by what you can assign in the current context (course or site). For example, if you have the teacher role in a 1.7 course, you will not be able to map students onto admins in the restored course. There is also an option to create new roles to map onto.
Different defaults may be set for restoring and merging into another course and for restoring and deleting the course contents.


==Restoring a course from the site files==
==Course restore capabilities==


The [[Site files|site files]] folder may be used for uploading a course backup zip file prior to restoring it. For security reasons, in versions of Moodle prior to 1.9.6 it is recommended that the backup file is deleted immediately after restoring it. In Moodle 1.9.6 onwards, backup files should be saved in the secure backupdata folder only.
* [[Capabilities/moodle/restore:createuser|Create users on restore]]
* [[Capabilities/moodle/restore:configure|Configure restore options]]
* [[Capabilities/moodle/restore:restoreactivity|Restore activities]]
* [[Capabilities/moodle/restore:restorecourse|Restore courses]]
* [[Capabilities/moodle/restore:restoresection|Restore sections]]
* [[Capabilities/moodle/restore:restoretargetimport|Restore from files targeted as import]]
* [[Capabilities/moodle/restore:rolldates|Roll activity configuration dates on restore]]
* [[Capabilities/moodle/restore:uploadfile|Upload files to backup areas]]
* [[Capabilities/moodle/restore:userinfo|Restore user data]]
* [[Capabilities/moodle/restore:viewautomatedfilearea|Restore courses from automated backups]]
 
==Restore via CLI for administrators==
 
{{New features}}In Moodle 3.10 onwards, site administrators can restore large backup files using a CLI script.
 
Options:
-f, --file=STRING          Path to the backup file.
-c, --categoryid=INT        ID of the category to restore too.
-s, --showdebugging        Show developer level debugging information
-h, --help                  Print out this help.
 
Example:
$sudo -u www-data /usr/bin/php admin/cli/restore_backup.php --file=/path/to/backup/file.mbz --categoryid=1


==See also==
==See also==


*[[Course backup]]
* [[Restoring file aliases]]
*[[Roll courses forward]] (in Moodle 1.7 onwards) how to repeat a course again
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI
*[[Import course data]] or parts of your other courses (in Moodle 1.6 onwards)
*[http://www.youtube.com/watch?v=mR9bsPBBWls Video showing how to restore a course backup file in Moodle]
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=90624 upload course & use?] forum discussion


[[Category:Backup]]
[[Category:Course]]


[[fr:Restauration]]
[[fr:Restauration de cours]]
[[ja:リストア]]
[[ja:リストア]]
[[es:Restaurar_un_curso]]
[[es:Restaurar_un_curso]]
[[ca:Restaurar_un_curs]]
[[de:Kurswiederherstellung]]
[[de:Kurswiederherstellung]]

Latest revision as of 11:36, 3 February 2021

Restoring a course backup

A course backup file (.mbz) may be restored from within any existing course for which you have permission. During the restore process, you will be given the option to restore as a new course or into an existing course.

Overview of course restore. (Instructions are for MoodleCloud but also apply to other sites.)
  1. With the Boost theme click the gear menu and then 'Restore' Otherwise, go to Site administration > Front page settings > Restore (if you have front page permissions) or Administration > Course administration > Restore (if you have an empty course to restore into.)
  2. Upload the backup file or choose a file in the course backup area or user private backup area and click Restore
  3. Confirm - Check that everything is as required then click the Continue button
  4. Destination - Choose whether the course should be restored as a new course or into an existing course then click the Continue button
  5. Settings - Select activities, blocks, filters and possibly other items as required then click the Next button
  6. Schema - Select/deselect specific items and amend the course name, short name and start date if necessary then click the Next button
  7. Review - Check that everything is as required, using the Previous button if necessary, then click the 'Perform restore' button
  8. Complete - Click the continue button

Notes:

  1. If you are restoring a course with user data (forum posts for example) then the user data will keep the original dates, whereas the activities and sections will change according to the new course start time you set.
  2. If your new course has fewer sections than the course you are restoring, the extra sections will appear as "orphaned activities". Increase the number of sections in the new course to make them visible.
  3. If you are restoring a course from a different Moodle site and you obtain the error message "Trying to restore user (admin) from backup file will cause conflict", you can enable the setting 'Allow admin conflict resolution' in Site admin > Courses > Backups > General import defaults
  4. When restoring a course containing calendar events from activities e.g. assignment due dates, these events will appear in the calendar a short while after restoring the course. The events are added to the calendar via a cron task. Restoring multiple courses will result in queued tasks with a possible delay before events appear in the calendar.

Restoring from course and category management screens

Users with permission to access Site administration > Courses > Manage courses and categories or Site administration > Courses > Manage courses and categories > (Category name) can restore courses from here:

Boost theme
Non-Boost themes

General restore defaults

An administrator can set defaults and lock selected restore settings in 'General restore defaults' in the Site administration. If a setting is locked, then it can not be changed when restoring a course.

Different defaults may be set for restoring and merging into another course and for restoring and deleting the course contents.

Course restore capabilities

Restore via CLI for administrators

New feature
in Moodle 3.10!
In Moodle 3.10 onwards, site administrators can restore large backup files using a CLI script.

Options:

-f, --file=STRING           Path to the backup file.
-c, --categoryid=INT        ID of the category to restore too.
-s, --showdebugging         Show developer level debugging information
-h, --help                  Print out this help.

Example:

$sudo -u www-data /usr/bin/php admin/cli/restore_backup.php --file=/path/to/backup/file.mbz --categoryid=1

See also