Moosh course-restore

Moosh course-restore

by Chris Nelson -
Number of replies: 7

I have a new moodle instance of 3.6.1. We are also using IIS8, PHP 7.2 and MariaDb10x.

I backed up 3 courses from an old instance of moodle 2.6 and restored to the new moodle site successfully.

We have many courses to backup and restore. 

i have moosh installed on the new server. I am able to run some commands, but am having issues with the course-restore command.

I know there is no support for moosh on windows, but I am hoping someone can see something I may be missing as to why I cannot do a moosh course restore. Here is the command I am using:

C:\inetpub\wwwroot\moodle>php c:\moosh\moosh.php -n course-restore c:\DoNotDelete\courses\backup-moodle2-course-240-blackbaud-20190102-1902-nu.mbz 11

11 is category ID for category where I want the course restored to.

The error I get is as follows:

Backup file 'C:\inetpub\wwwroot\moodle\c:\DoNotDelete\courses\backup-moodle2-course-240-blackbaud-20190102-1902-nu.mbz' does not exist.

Any suggestions as to the error message?

Or is there another way to do bulk course restores not using Moosh?

Thank you

Average of ratings: Useful (1)
In reply to Chris Nelson

Re: Moosh course-restore

by Ken Task -
Picture of Particularly helpful Moodlers

Don't run Windows, but ... here's an idea/thought.

Moosh is like the scripts in moodlecode/admin/cli/ in that the commands have to be run from inside moodle code ... things like the cli libraries, the DB info, etc. need to be known ... which it gets from config.php.

So ... copy the c:\DoNotDelete\courses\ backup files to a directory in moodle code directory .... 

In C:\inetpub\wwwroot\moodle\ create a directory called 'xfer' ... that directory name doesn't exist in moodle code.

Then run the commands as you did before only  pointed to the 'xfer' directory to find the .mbz's.

Am not aware of any other way.   Is it time to move to Linux?

Good Luck!

'spirit of sharing', Ken


Average of ratings: Useful (2)
In reply to Ken Task

Re: Moosh course-restore

by Chris Nelson -

Thanks Ken, that did the trick. now I need to build a script so I can do many course restores with one click.

In reply to Chris Nelson

Re: Moosh course-restore

by Ken Task -
Picture of Particularly helpful Moodlers

Lucky, guess, huh? smile [since I don't do Windows].

Suggest taking it slow in the beginning ... set the the 'one click' to do X courses in just one category ... categories have to pre-exist.

When I did similar on Linux, backups for a category were placed in a category 'place holder' directory.

Script then run where all the backups there in the 'place holder' went to a category ID.

Spent most of my time just getting things organized.  Then repetitive repeat of commands for new category.

Hopefully, one won't be doing things this way in the future.

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Moosh course-restore

by Chris Nelson -

Questions regarding moosh course-restore:

I am running the following moosh command:

php c:\moosh\moosh.php -n course-restore xfer\backup-moodle2-course-31-xxxxxxxxxx-20190210-0116.mbz 55

I get the following message:


C:\inetpub\wwwroot\moodle>php c:\moosh\moosh.php -n course-restore xfer\backup-moodle2-course-31-xxxxxxxxxx-20190210-0116.mbz 55 -Creating new course to restore backup - Restoring (new course id,shortname,destination category): 10,MIN 243 DAllen F201 7,55

Requested course 10 does not have idnumber, no sync performed. New course ID for 'MIN 243 DAllen F2017': 10 in category 55


The course is created under correct category however I am not sure if there will be an issue with the Course ID

Right now the courses I am restoring have no students or teachers in it.

Soon I will be bringing over courses with both student and teachers and my concern is these courses are still active ones and I am wanting to make sure there will be no issues with student being placed in the right courses with their present material such as forum responses, quiz results etc.

We use ldap authentication and ldap enrolment

Thoughts?

In reply to Chris Nelson

Re: Moosh course-restore

by Ken Task -
Picture of Particularly helpful Moodlers

Thoughts ... you asked for and thoughts are below.

Qualification for this response: NONE ... I don't run windows ... so consider this kinda a guess that might lead to a resolution on platform. smile

First, the author of moosh does say that it might not run all commands on Windows platform.

Moosh is a command line utility ... the command you show has 'php' in front.

If you were to be in same directory where you issued the moosh command, what do you get for just:

php -v

If your system is finding the php-cli the above command should show something like this:

PHP 7.0.33 (cli) (built: Jan  7 2019 20:13:36) ( NTS )

Note the (cli).

Where is your operating systems php-cli?

moosh.php file itself has a 'shebang' at the top of the file.

Might open that file and see what the 'shebang' is pointed to.

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Moosh course-restore

by Chris Nelson -

php -v yields:

C:\inetpub\wwwroot\moodle>php -v

PHP 7.2.14 (cli) (built: Jan  9 2019 22:23:14) ( NTS MSVC15 (Visual C++ 2017) x6

4 )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

    with Zend OPcache v7.2.14, Copyright (c) 1999-2018, by Zend Technologie


moosh.php "shebang" points to !# /usr/bin/env php

Maybe I am not understanding the result:  "Requested course 10 does not have idnumber, no sync performed. New course ID for 'MIN 243 DAllen F2017': 10 in category 55

Yet if I look at the course the course idnumber is part of the file name:  i.e. backup-moodle2-course-31......


Would idnumber come over as part of the back up? 

As I understand the above message: since the course being restored has no idnumber it has been assigned an idnumber =10.

The question then is how important is this idnumber when I import a course with faculty and students as users in the course?

In reply to Chris Nelson

Re: Moosh course-restore

by Ken Task -
Picture of Particularly helpful Moodlers

??? Dunno but how long would it take someone to go back into a course and add an ID number on existing server If that is the issue?

If all you have are the backups, might have to un-compress a copy of a course and see what it says in moodle_backup.xml for a course ID.   Guess there could be some character or combo of characters in there that could cause moosh confusion ... dunno ... just guessing now.

In doing the same thing on Linux servers I know for a fact that ID numbers were not in the course configs nor backups and had no such issue upon command line restore ... just had to have the categories in new site populated so I could use the category ID to restore.

'spirit of sharing', Ken


Average of ratings: Useful (1)