Utilities: moosh

Maintained by Picture of Tomasz Muras Tomasz Muras
Moosh stands for MOOdle SHell. It is a commandline tool that will allow you to perform most common Moodle tasks. It's inspired by Drush - a similar tool for Drupal.
16 fans
Moodle 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1

Moosh is a tool that exposes some common Moodle functionality to the commandline.

You install moosh outside of the Moodle directory, it can be anywhere really. Then simply make moosh.php (or symlink named like moosh) available somewhere in $PATH.

To run moosh, change the directory into your installed Moodle's instance and run one of the commands. To get the list of all available commands only run moosh.php (or just moosh if you've symlinked it like this) or read the documentation and examples.

Moosh is meant to work nicely with Linux features like bash/zsh expansion. For example, to create 10 users, you just type:

% moosh user-create username{1..10}



Screenshot #0


Picture of Tomasz Muras
Tomasz Muras (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • David
    Tue, 24 Sep 2013, 5:43 AM
    this is a great extension Thomasz, do you think it would be possible to extend the course section with the import from course functionality? That way its super easy to clone a course, without having to make a backup and restore. (alternatively course_clone would be even more awesome!)
  • Picture of Howard Miller
    Fri, 28 Feb 2014, 8:02 PM
    It only seems to work when logged in as root. I assume I am missing some permissions. The command runs but doesn't find any commands. What are the permissions for 'moosh'?
  • Picture of Joby Harding
    Sun, 8 Jun 2014, 11:36 PM
    I'm a big fan of Drush great to have something similar for Moodle.

    One question though - how to run the unit tests? Grepped the commands list for 'test' and 'unit' but can't spot anything. I've tried running tests/run-tests.php directly but I get an error about a missing file when run in the tests directory and a failed include when run from the Moosh root.

    I'm probably missing something obvious but a pointer would be greatly appreciated as I'd like to add a couple of tests for some additions I've made.

  • Picture of Vikram Solia
    Thu, 28 Aug 2014, 10:42 PM
    Great plugin for developers and testers. It would be nice to have a command set for cloning and renaming existing plugins. What do you think?
  • Picture of David Mudrák
    Mon, 20 Apr 2015, 11:22 PM

    I am happy to announce that moosh just received our Featured Moodle plugin award. Read the interview with the maintainer at the Plugins traffic blog post.

    Well done Tomek, and thanks for your work on this!

  • Picture of Eduardo Hm
    Thu, 21 May 2015, 4:21 PM
    Good morning

    I have been tested this utility and the truth that is a breakthrough because it allows you to facilitate the use of the most common tasks you want to perform on moodle without having to be entering the platform.

    This utility basically I'm using for backup and restoration courses thereof. After several tests, when performing certain restorations of certain courses, the course moosh-restore process gives me the following error message and will stop. I generated the course but not the content of the course:

    [root@xxxx]# moosh course-restore LOPD.mbz 2
    Restoring (new course id,shortname,destination category): 19,LOPD_3,2
    Default exception handler: error/restore_not_executable_awaiting_required Debug:
    Error code: restore_not_executable_awaiting_required
    $a contents: 600
    * line 164 of /backup/util/plan/restore_plan.class.php: restore_controller_exception thrown
    * line 333 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
    * line 150 of /root/actualizaMoodle/moosh/Moosh/Command/Moodle23/Course/CourseRestore.php: call to restore_controller->execute_plan()
    * line 243 of /root/actualizaMoodle/moosh/moosh.php: call to Moosh\Command\Moodle23\Course\CourseRestore->execute()

    !!! error/restore_not_executable_awaiting_required !!!

    Why do I get this error for some restorations and to other restorations goes perfectly well?

    Regards and congratulations for this plugin!!!!
  • Picture of Andreas Grupp
    Thu, 10 Sep 2015, 6:26 PM
    I installed moosh in version 0.19 which is the current release of moosh at the time of this comment. When I start moosh I get an error message saying that moosh.php is not able to load the required file "vendor/autoload.php" in the moosh installation directory. Indeed there is no file available with this name in the vendor subdirectory. In my older moosh installation (version 0.18) this file, and serveral others including further subdirectories, is available. Any idea how I can solve this?

  • Picture of Tomasz Muras
    Fri, 11 Sep 2015, 7:35 PM
    Hi Andreas,

    Something went wrong when I was doing 0.19 release. I'll need to do another one that fixes it, I suggest you use 0.18 until that happens (in about 1 week).

    Thanks for reporting it,
  • Chris Schembri Baldacchino's Pic
    Fri, 19 Feb 2016, 4:29 PM
    Hi... This plugin seems amazing! Any plans to have it available for Moodle 3.0?
  • Picture of Francis Feytout
    Thu, 24 Mar 2016, 5:29 PM
    Hi, I'm looking for a way to do mass backup/reset/restore, but looks like the current version doesn't support those. Do you have any plan to get that to work for 2.7+ ?
  • Picture of Tomasz Muras
    Sat, 26 Mar 2016, 4:26 AM
    Chris - most of the commands should just work with Moodle 3.0 - if any does not, report it on github.
    Francis - those are already supported. For example course backup: http://moosh-online.com/commands/#course-backup :
    to backup several coursed based on id, you combine moosh with a bit of bash, for example backup courses with IDs 1,2,3...100:
    for c in $(seq 1 100)
    moosh course-backup $i
  • Picture of Francis Feytout
    Wed, 30 Mar 2016, 5:45 PM
    Thank you Thomas, I was basing myself on the red Xs from your site ( http://moosh-online.com/ci/ ). I will report some issues on github them. Great job so far !
  • Picture of wz z
    Wed, 25 May 2016, 9:30 PM
    I hope it can run on PHP 7.
  • Picture of Tomasz Muras
    Fri, 5 Aug 2016, 3:14 AM
    Yes, it does run with PHP7:

    vagrant@vagrant:~/moosh$ php --version
    PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies

    vagrant@vagrant:~/moosh$ ./moosh.php
    moosh version 0.21
    No command provided, possible commands:
  • Picture of Henry Chung
    Mon, 22 Aug 2016, 8:00 PM
    I'm getting an error when I'm using user-delete:

    PHP Fatal error: Call to undefined function get_sorted_course_formats() in /moodleapp/course/format/lib.php on line 103

    it eventually works after a couple of tries and the user is deleted.
    I've tried upgrading to the latest moosh version but still getting the same error, tried on Moodle 2.8/2.9 and both give same error
1 2
Please login to post comments