Course restore: Difference between revisions

From MoodleDocs
m (Link updated)
(updated video to 4.3)
 
(16 intermediate revisions by 5 users not shown)
Line 4: Line 4:
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.  
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.  


{{MediaPlayer | url = https://youtu.be/7ZMvdf9mwcQ | desc = Overview of course restore. (Instructions are for MoodleCloud but also apply to other sites.)}}
{{MediaPlayer | url = https://youtu.be/r6Ko6qxHAJY | desc = Overview of course restore. (Instructions are for MoodleCloud but also apply to other sites.)}}


# 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.)
# From the Manage categories and courses screen, click the arrow next to the chosen category and click  'Restore (if you have admin or category permissions) or ''Course navigation > More > Course reuse > Restore'' if you are restoring into a course.
# Upload the backup file or choose a file in the course backup area or user private backup area and click Restore
# 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
# Confirm - Check that everything is as required then click the Continue button
Line 17: Line 17:
Notes:
Notes:


# '''New in 3.4:''' 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.
# 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.
# 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.
# 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.
# 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''
# 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''
# In Moodle 3.3.2 onwards, 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. (See MDL-58906 for further details.)
# 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==
==Restoring from course and category management screens==
Line 27: Line 27:


{|
{|
| [[File:RestoreBoost.png|thumb|300px|Boost theme]]
| [[File:RestoreBoost.png|thumb|400px|Boost theme]]
| [[File:courserestorecategory.png|thumb|300px|Non-Boost themes]]
| [[File:courserestorecategory.png|thumb|200px|Non-Boost themes]]
|}
|}


Line 36: Line 36:


Different defaults may be set for restoring and merging into another course and for restoring and deleting the course contents.
Different defaults may be set for restoring and merging into another course and for restoring and deleting the course contents.
== Restorer role assignment==
The setting in ''Site administration > Users > Permissions > User policies > Restorers' role in courses'' controls whether a user doing a course restore will be assigned a role in the restored course or not. If a user doing a course restore does not already have the permission to manage the newly restored course, the user is automatically assigned a new role and enrolled if necessary.
The default role is Teacher. So a user restoring a course who does not already have the Teacher role in the course, will be assigned the Teacher role.
For example, if you have granted the role of Non-editing teacher the additional rights to restore courses (for example into an already existing shell or merging) or import content from other courses, then they would be assigned the role of Teacher as well in courses they restore.
Select "None" from the options for this setting if you do not want restorers to be able to manage every restored course.
==Error: The file you tried to upload is too large for the server to process.==
See [[File upload size]] to fix this.


==Course restore capabilities==
==Course restore capabilities==
Line 44: Line 57:
* [[Capabilities/moodle/restore:restorecourse|Restore courses]]
* [[Capabilities/moodle/restore:restorecourse|Restore courses]]
* [[Capabilities/moodle/restore:restoresection|Restore sections]]
* [[Capabilities/moodle/restore:restoresection|Restore sections]]
* [[Capabilities/moodle/restore:restoretargethub|Restore from files targeted as hub]]
* [[Capabilities/moodle/restore:restoretargetimport|Restore from files targeted as import]]
* [[Capabilities/moodle/restore:restoretargetimport|Restore from files targeted as import]]
* [[Capabilities/moodle/restore:rolldates|Roll activity configuration dates on restore]]
* [[Capabilities/moodle/restore:rolldates|Roll activity configuration dates on restore]]
Line 50: Line 62:
* [[Capabilities/moodle/restore:userinfo|Restore user data]]
* [[Capabilities/moodle/restore:userinfo|Restore user data]]
* [[Capabilities/moodle/restore:viewautomatedfilearea|Restore courses from automated backups]]
* [[Capabilities/moodle/restore:viewautomatedfilearea|Restore courses from automated backups]]
==Restore via CLI for administrators==
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==
Line 55: Line 79:
* [[Restoring file aliases]]
* [[Restoring file aliases]]
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI
[[Category:Course]]


[[fr:Restauration de cours]]
[[fr:Restauration de cours]]

Latest revision as of 19:56, 28 November 2023

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. From the Manage categories and courses screen, click the arrow next to the chosen category and click 'Restore (if you have admin or category permissions) or Course navigation > More > Course reuse > Restore if you are restoring into a course.
  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.

Restorer role assignment

The setting in Site administration > Users > Permissions > User policies > Restorers' role in courses controls whether a user doing a course restore will be assigned a role in the restored course or not. If a user doing a course restore does not already have the permission to manage the newly restored course, the user is automatically assigned a new role and enrolled if necessary.

The default role is Teacher. So a user restoring a course who does not already have the Teacher role in the course, will be assigned the Teacher role.

For example, if you have granted the role of Non-editing teacher the additional rights to restore courses (for example into an already existing shell or merging) or import content from other courses, then they would be assigned the role of Teacher as well in courses they restore.

Select "None" from the options for this setting if you do not want restorers to be able to manage every restored course.

Error: The file you tried to upload is too large for the server to process.

See File upload size to fix this.

Course restore capabilities

Restore via CLI for administrators

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