Attempting to restore a backup of the front page from a Moodle 2.7 installation to the front page of a new Moodle 3.0 installation it failed with the message "You can only restore front page backups on the front page"
I found a tracker which references this error, MDL-51448 but since Moodle Tracker is not accepting new accounts I thought to document how I worked around it here.
In /backup/util/helper/restore_prechecks_helper.class.php I found the following code:
// The original_course_format var was introduced in Moodle 2.9. $originalcourseformat = null; if (!empty($controller->get_info()->original_course_format)) { $originalcourseformat = $controller->get_info()->original_course_format; } // We can't restore other course's backups on the front page. if ($controller->get_courseid() == SITEID && $originalcourseformat != 'site' && $controller->get_type() == backup::TYPE_1COURSE) { $errors[] = get_string('errorrestorefrontpagebackup', 'backup'); } // We can't restore front pages over other courses. if ($controller->get_courseid() != SITEID && $originalcourseformat == 'site' && $controller->get_type() == backup::TYPE_1COURSE) { $errors[] = get_string('errorrestorefrontpagebackup', 'backup'); }
This tests the state of the 'original_course_format' xml variable in the moodle_backup.xml file in the moodle backup it is trying to restore but does not seem to do anything useful in situations where that variable does not exist, pre 2.9.
As a work-around I unzipped the backup file from 2.7 then edited moodle_backup.xml to add the line:
<original_course_format>site</original_course_format> after the original_course_id line
Repacked the backup as a zip file, changed the extension from .zip to .mbz and successfully restored it to the front page course to the moodle 3.0 site as a full replacement.
So far this has only been used on a testing installation of Moodle 3.