Mass restore of courses

Re: Mass restore of courses

by Ken Task -
Number of replies: 5
Picture of Particularly helpful Moodlers

Not aware of any GUI plugin that does what you need done, however, there are a couple of ways via CLI:

https://docs.moodle.org/404/en/Course_restore#Course_restore_capabilities
a looping bash shell script used with:
https://docs.moodle.org/404/en/Course_restore#Restore_via_CLI_for_administrators
or
Moosh - a command line moodle utility
https://moosh-online.com/commands/#course-restore
again a looping bash script.

Maybe you need to share this response with the persons that do have CLI access. smile

'SoS', Ken

In reply to Ken Task

Ri: Re: Mass restore of courses

by moodle consultant -
Hi everyone,
By performing the restore via the cli, the course name is replaced with a progressive number, which essentially makes this function useless (example: backup and restore of > 100 courses).
In reply to moodle consultant

Re: Ri: Re: Mass restore of courses

by Ken Task -
Picture of Particularly helpful Moodlers

@moodle consultant

Is your purpose the same as the original poster in this thread?   Migration to new server?   Or you are NOT migrating and want to keep the same courses for next year but loose the students?

If your goal is to provide same courses for your next academic calendar year (something like that), then the better tool is reset.   And since you have command line reset using Moosh.

I do this every year for a k12 entity after their grades have been turned in and school is out for the summer.

https://moodle.org/plugins/view.php?id=522

Moosh commands

https://moosh-online.com/commands/#course-reset

'SoS', Ken

In reply to Ken Task

Ri: Re: Ri: Re: Mass restore of courses

by moodle consultant -
Hi Ken, thank you for your reply.
yes, my purpose is almost the same. I need to backup a lot of courses ( > 200) from an old moodle and restore to a new installation.
I backed up all the courses and uploaded them to a dedicated area on the new server and restored them via cli.
I tried with a sh script but the result is as described (courses with a progressive number instead of the name). reading the php code of the file admin/cli/restore_backup.php, I can see that both corse fullname ad shortname are generated in a method called calculate_course_names and are not readed in the backup file.
Maybe I'm doing something wrong?

I've never used moosh, but I imagine it uses moodle's internal methods anyway.

Thank you
In reply to moodle consultant

Re: Ri: Re: Ri: Re: Mass restore of courses

by Ken Task -
Picture of Particularly helpful Moodlers

Think that only happens when the course you are restoring is already in existence.

Have been cleaning up a 4.1.highest site and was deleting courses (64 to be exact) that had not be used in years when I made a boo-boo and deleted one course that was hidden from view.   Prior to deletions I made backups of those hidden courses.  Teacher wanted to be able to get resources from that course and asked that it be restored.   Restore done via moosh ... it came back in to same category where it was before - hidden - had a new ID - which was expected but no duplication ... course did not exist.

Not sure that moosh uses the same routines/code as the backup/restore scripts found in code/admin/cli/.    One way to find out ... install moosh and do just one restore to a category ... that course doesn't exist in that category.   You'll find other uses for moosh when it comes to massive stuff.

How old are those courses? (version of Moodle?)

'SoS', Ken