error/cannot_precheck_wrong_status when restoring backup mbz

error/cannot_precheck_wrong_status when restoring backup mbz

by Andi Rahmat -
Number of replies: 4

I have an error restoring a backup.(error/cannot precheck_wrong_status)

I check the script in restore_includes.php :

// Schema Restore backup into course.
            $controller = new restore_controller($folder, $course_id, backup::INTERACTIVE_NO, backup::MODE_SAMESITE, $userdoingrestore, backup::TARGET_NEW_COURSE);
              
            //error when execute_precheck
            $controller->execute_precheck();
           
            $controller->execute_plan();
            $transaction->allow_commit();
            // end Schema Restore backup into course.
           
            //print_r($folder, $course_id); //die();

I attached the screenshoot and file backup.mbz

Attachment 1.JPG
Average of ratings: -
In reply to Andi Rahmat

Re: error/cannot_precheck_wrong_status when restoring backup mbz

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Could you turn debugging on and see if you get a more detailed error?

In reply to Andi Rahmat

Re: error/cannot_precheck_wrong_status when restoring backup mbz

by Ken Task -
Picture of Particularly helpful Moodlers

Me thinks you have a role in the backup file causing the issue +  a non-interactive setting?

So do this:

Extract your backup.mbz

tar zxvf backup.mbz

edit moodle_backup.xml file

Change the following:
<name>role_assignments</name>
Value set to 0 ... not 1.

<interactive></interactive>

Set to 1:
<interactive>1</interactive>

re-package the .mbz

tar -czvf backup.mbz *

When restoring and you get to the interactive part, make sure
you do NOT restore roles ... un-check if there is a box for you to decide.

Resorting a course that might have an admin account level in it conflicts
with admin users already in the system.

Might consider creating backups with no roles in future ... especially IF you
have an admin level user in a course.  You can always re-assign roles to the course.

BTW, tested this on a 2.8.highest version of Moodle and it failed the first time ... almost right off the bat.   The suggested error link didn't mention specifics enough.    So I inspected and compared a valid/working .mbz backup to yours.

After making the changes to the moodle_backup.xml file above, restored without issue ... **did un-check option to restore roles on my system** ... for obvious reasons.

'spirit of sharing', Ken


In reply to Ken Task

Re: error/cannot_precheck_wrong_status when restoring backup mbz

by Andi Rahmat -

Dear Ken and Emma,

Thank you for your respons

actually I made Aplication that execute moodle core. The Aplication run to make a backup.mbz from course in LMS Server and then restore it to LMS Client.

The backup.mbz file succesfull create in temp but when restoring i got error precheck status

Already set debug on in config file

@ini_set('display_errors', '1');
$CFG->debug = 38911;
$CFG->debugdisplay = true;  

Attachment Capture 1.JPG
In reply to Andi Rahmat

Re: error/cannot_precheck_wrong_status when restoring backup mbz

by Ken Task -
Picture of Particularly helpful Moodlers

Welcome.  Interesting.   All I can tell ya I've said in the previous response - making edits to the backup's moodle_backup.xml file  shared with you, the course restored without the error you are seeing.

Since this is really an app/addon you've programmed might I suggest moderator move this to the forum for developers cause I think this is a development question.

'spirit of sharing', Ken