A few years ago I made some CLI scripts to backup courses at the end of each of our terms, then delete them from moodle. That system works fine. All files are created without errors and every backup file ever made to date will restore properly, interactively.
We have had to do a few spot-restores of courses so that instructors can get information they need, and then we archive them again. So we do those course restores interactively. Not a problem.
Now, the Dept of Education is coming and the school needs more detailed data on grades historically than can be found in the final course grades. We store the course grades in our SMS system, but not the individual items that make up each grade. Those details are only in these backups since the courses have been removed from Moodle, and there are thousands of these backups.
As you can imagine, having someone manually restore thousands of backup files is very time consuming. So I have written a program to automatically restore files. But it is erroring with "cannot_precheck_wrong_status" right after I call for the the restore controller to precheck.
Here's a snip of my code where the error occurs. The error happens on the line $controller->execute_precheck();
// Restore backup into course echo "creating restore_controller\r\n"; $controller = new restore_controller($shortname, $courseid, backup::INTERACTIVE_NO, backup::MODE_SAMESITE, 2, backup::TARGET_NEW_COURSE); echo "executing controller precheck\r\n"; $controller->execute_precheck(); echo "executing controller plan\r\n"; $controller->execute_plan(); echo "destroyng controller\r\n"; $controller->destroy();
I am looking for ideas on how to cross this bridge. The Dept of Education is coming and the bosses are pressing me for an ETA on when I'm going to have this fixed so they can prepare their report data they need.