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.
21 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, 3.2, 3.3

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
  • 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
  • Picture of sreenu eabyas
    Fri, 26 May 2017, 7:22 PM
    Is it possible backup and restore an activity using moosh?
  • Picture of Tomasz Muras
    Sat, 27 May 2017, 4:38 AM
    At the moment the only backup implemented is backup::TYPE_1COURSE (whole course) in course-backup command.
  • Picture of Bernat Martinez
    Mon, 31 Jul 2017, 7:20 PM
    Is it possible delete multiple users filtering by role? (moosh user-delete)
    Thank's in advance
  • Picture of Jock Coats
    Thu, 30 Nov 2017, 10:40 PM
    Hi Tomasz, this looks amazing. I haven't tried it yet, but looked through the documentation and wondered, can I give it a file for its input. I wish to delete lots and lots of users, and was trying to use "User Upload" with a csv of usernames with the delete flag on but it's running so slowly and wondered if I could use a command line version like this.


    Jock Coats
  • Picture of Tomasz Muras
    Tue, 5 Dec 2017, 1:01 AM
    Hi Jock,

    moosh user-delete does not accept a file as an input (see https://moosh-online.com/commands/#user-delete) but you can use a power of Linux command line and simply do something like:
    cat file_with_user_names.txt | xargs moosh user-delete
  • Picture of Jock Coats
    Tue, 5 Dec 2017, 1:07 AM
    Thanks Tomasz. A colleague also pointed this out to me smile
1 2
Please login to post comments