Installing and upgrading help

Upgrade Moodle using Git with installed plugins

 
Picture of Christos Savva
Upgrade Moodle using Git with installed plugins
 

Hello


I was wondering what is the best way to update Moodle Core, when I have installed a lot of plugins on my Moodle instance.


I have read few older forum posts about the same question but I am still confused.


1. I have installed Moodle from Git.

2. I installed 10+ plugins

3. Now I want to update to latest 3.3 version 


How can I update Moodle core and keep the changes I made?


Kind regards

Christos

 
Average of ratings: -
Picture of Ken Task
Re: Upgrade Moodle using Git with installed plugins
Group Particularly helpful Moodlers

Key to your question ... involves another question ... was the Moodle originally installed using git to acquire the code?

Evidence of that ... in the moodle code directory there is a hidden .git directory.   Note the 'dot' in front of the word git.

So as not to confuse with options let's find out that first.

A general comment however ... git only updates/upgrades core code.   If plugins/add-ons were installed in the typical fashion (via Moodle Admin UI) those are not updated nor upgraded by the git commands to update/upgrade the core, but rather through the Moodle Admin UI (it's called mdeploy).

*** You must find out if the plugins/add-ons you've added are compatible with the version you are upgrading to.

A great tool to find out if a plugin has an X version is 'moosh' ... which is command line only.   More on that after we get by the first question.

'spirit of sharing', Ken



 
Average of ratings: -
Picture of Christos Savva
Re: Upgrade Moodle using Git with installed plugins
 

Yes Moodle was initially installed using git, the .git folder is present


If I use


git status


there are few Untracked files, if I just git pull will this upgrade Moodle Core files without affecting plugins?


I am interested to upgrade Moodle Core only, I dont worry about upgrading plugins.

 
Average of ratings: -
Picture of Ken Task
Re: Upgrade Moodle using Git with installed plugins
Group Particularly helpful Moodlers

That command id's files that git doesn't recognize as part of core obtained previously.

Example:

I have some bash shell scripts and text files related in /moodlecode/admin/cli/  None of those change core code.

# On branch MOODLE_33_STABLE
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    admin/cli/checkaddons
#    admin/cli/clirestore
#    admin/cli/courses.txt
#    admin/cli/dobu
#    admin/cli/get1courseinfo
#    admin/cli/getcourseinfo
#    admin/cli/getcourses
#    bu
#    mod/lightboxgallery/
#    up
nothing added to commit but untracked files present (use "git add" to track)

To update ... ie, acquire updates to the version you have ...

check:

git branch -a

At the top:

* MOODLE_33_STABLE

shows am tracking the 33 branch.

root@sos moodle33]# fgrep '$release' version.php
$release  = '3.3.1 (Build: 20170710)'; // Human-friendly version name

git pull would aquire any/all updates to the 33 branch

To upgrade, however, one must issue two commands to track the next highest branch.

# git branch --track MOODLE_34_STABLE origin/MOODLE_34_STABLE;
# git checkout MOODLE_34_STABLE;

Again ... it's important to check if the addons have a compat version.   The upgrade process will check and in some cases, might stop your upgrade cold.

This is where a bash shell script using moosh comes in handy.

addons.txt is a simple text file listing the true name of an addon.

The script, checkaddons, reads the lines in addons.txt one at a time, then uses moosh to see what's available for that addon:

#!/bin/bash
#
echo 'Add-on listing: ';
cat ./addons.txt;
echo '---------------------';
for i in `cat ./addons.txt`
do
   echo "Addon in que: $i";
moosh plugin-list |grep '^'$i
done

Again ... IF an addon doesn't have a compat version for the upgraded version you are moving to, it could cause problems - in some cases, major ... like themes.

moosh uses config.php and the moosh command above issued by itself should acquire infor on *all* plugins - even ones you don't have installed.

Output looks like:

workshopeval_weightiest,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2,3.3,https://moodle.org/plugins/download.php/11123/workshopeval_weightiest_moodle33_2015042200.zip

The mod/addon workshopeval_weightiest has compat versions for 2.5->3.3.  IF I had the addon installed and was upgrading site to 3.3 then that addon should continue to function ... after upgrading it via the Moodle admin UI.

That clear as mud? ;)

Might be a good thing to have a clone of production to test before applying on production server.

Cravat ... if you installed a plugin via git, then you could change into that directory and a git pull there should work like the git pull does with core ... acquires updates to just that plugin ... directory has it's own hidden .git directory.

'spirit of sharing', Ken


 
Average of ratings: Useful (1)
Picture of Christos Savva
Re: Upgrade Moodle using Git with installed plugins
 

Thank you soooooooooo much for the detailed reply.


Now its clear! Thank you.


I will try to also use Moosh as per your recommendation 


Thank you again

 
Average of ratings: -
Picture of Ken Task
Re: Upgrade Moodle using Git with installed plugins
Group Particularly helpful Moodlers

Welcome.   Feel free to rate postings that were useful as 'useful' ... helps me keep my 'badge'. ;)

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Christos Savva
Re: Upgrade Moodle using Git with installed plugins
 

Dear Ken


Hi again, I tried to use Moosh, but it does not always work.


I downloaded Moosh from git and created a symlink to /usr/local/bin.


When I do

moosh plugin-list

It works, I get a list of plugins

When I do

moosh course-create newcourse{1..3}
One of your Moodle data directories (/var/www/moodledata/cache) is owned by
different user (apache) than the one that runs the script (root).
If you're sure you know what you're doing, run moosh with -n flag to skip that test.

Then I try

sudo -uapache moosh course-create newcourse{1..3}
sudo: unable to execute /usr/local/bin/moosh: Permission denied


Did you ever had the same problem? Am running on Centos 7


Thanks in advance

 
Average of ratings: -
Picture of Ken Task
Re: Upgrade Moodle using Git with installed plugins
Group Particularly helpful Moodlers

The last line in the notice 'if you know what you are doing ...' ... -n skips the check to run moosh as web service user and will allow execution as the root user.   I know some will shudder at that ... might even be a little afraid to run as root user, but ... we do as we must when it comes to Moodle.

Something might get tagged as belonging to the root user when it comes to files/folders .. owerships/permissions fixes are easy and I'll gladly trade off having to do that IF moosh can do things it advertises it can do.  

Moosh reads the config.php file and takes DB info from it when working with DB.  And think one needs to execute commands inside the code diretory so that it can read that config.php.

Sooooo ... all that to say, be less afraid! smile    Issue the command inside the code directory.

moosh -n course-create newcourse{1..3}
as root.

'spirit of sharing', Ken

 
Average of ratings: Useful (1)
Picture of Christos Savva
Re: Upgrade Moodle using Git with installed plugins
 

To be honest i got scared from the documentation and didnt want to run the command with -n smile


I will run it as root then thanks smile

 
Average of ratings: -