Restoring Course from CLI into a New Course

Restoring Course from CLI into a New Course

Jennifer Blandino གིས-
Number of replies: 2
Hello:

I have an NSI installer I wrote a while back that, among other things, runs CLI commands to restore courses. Currently, my installer runs the php commands like so:

nsExec::Exec 'php ${Apache_HTDOCS_FOLDER}\lms\admin\cli\restore_backup.php --file "$INSTDIR\Module_Backups\${MODULE_A_FILE}" --categoryid=${MODULE_A_CATEGORY}'

Where:

${Apache_HTDOCS_FOLDER} - is the server directory where the htdocs folder from Apache exists.
$INSTDIR - is a temporary location where the files my installer uses are being stored during processing
${MODULE_A_FILE} - is the filepath of a course backup mbz I intend to restore into the site.

As you can see, I'm making use of the php CLI to restore courses programmatically, and until now, this has worked wonderfully. However, it has become necessary for our business to, instead of deliver complete replacements for old courses, deliver new courses that are separate from the old ones. So, for example, if the mbz is storing a course ID that already exists on the destination system, I don't want that course to get restored into the old one; I want it be restored into a new course every time, regardless of whether the IDs match or not.

I have been unable so far to find where in the API the settings are to choose this mode for restoration. I can do it easily enough in the Moodle site interface, but I need to create a solution that does not rely on the end user admins restoring the courses, because they don't want to do it; they want a simple installer to do it all for them. སྐྱོ་བ།

Does anyone know if the option to "restore into new course" exists for the CLI, and if so, where it's defined? I'd like to be able to set a category for it, not include enrolled users, and give it a new course name and course short name, if possible. Is such a thing even possible from the command line?
དཔྱ་སྙོམས་ཀྱི་སྐུགས་ཚུ།: -
In reply to Jennifer Blandino

Re: Restoring Course from CLI into a New Course

Ken Task གིས-
Particularly helpful Moodlers གི་པར
Qualifications for this response: I don't run Windows, but ...

The 'swiss army knife' for Moodle is called moosh - cli only - and does a lot!


'SoS', Ken

In reply to Ken Task

Re: Restoring Course from CLI into a New Course

Jennifer Blandino གིས-
Unfortunately, our system is a Windows environment only system. I see the course-restore commands available in Moosh, and it does appear that it offers more than the barebones CLI does, but the author of Moosh has said that some things may not work in a Windows environment. I suppose that if I really have to, I might be able to reverse-engineer it if I had the source code for it. But I'm hoping I don't have to create such a complicated command line utility with or without moosh as an example.