New to upgrading 4.1.1 to 4.2.1 using Git

New to upgrading 4.1.1 to 4.2.1 using Git

by Trapline Jams -
Number of replies: 11
Hello all,

I am trying to upgrade my Moodle site to the newest version using the online documentation as a guide.  If I did not install Moodle using Git in the first place, is it too late to start using it now to upgrade?

I followed the step by step procedure found here-  https://docs.moodle.org/402/en/Upgrading
but there were quite a few errors that seemed to be related to missing plugins, so I thought using Git might make things run a lot smoother for this.  

Started using these docs as guides -


but this leads to Git wanting to create a new Moodle folder from scratch, whereas I want to keep all of my old plugins and config.

If anyone has any pointers for a newb, they would be grately appreciated.

Average of ratings: -
In reply to Trapline Jams

Re: New to upgrading 4.1.1 to 4.2.1 using Git

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

You said:
> I followed the step by step procedure found here-  https://docs.moodle.org/402/en/Upgrading

Just to be sure, you also followed steps 1 and 2 of https://docs.moodle.org/402/en/Upgrading, right?

> but this leads to Git wanting to create a new Moodle folder from scratch, whereas I want to keep all of my old plugins and config.

Why don't you let Git to start with a fresh Moodle 4.2 and copy the plug-in directories in to the new code tree? Or even cleaner, download the plug-ins - their 4.2 compatible versions - using Git in to the same places in the code tree.

P.S. In case you didn't notice, Moodle 4.1 (LTS) is destined to survive Moodle 4.2 and even 4.3! https://moodledev.io/general/releases
In reply to Visvanath Ratnaweera

Re: New to upgrading 4.1.1 to 4.2.1 using Git

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Noticed that I wasn't clear in my previous post. By "Why don't you let Git to start with a fresh Moodle 4.2 .." what I meant was to *replace* the old (4.1) code with the new (4.2.latest) code.
In reply to Visvanath Ratnaweera

Re: New to upgrading 4.1.1 to 4.2.1 using Git

by Trapline Jams -
This is what I had tried to do, but using the information available to me, combined with my level of experience, I was unable to find all the plugin locations.
In reply to Trapline Jams

Re: New to upgrading 4.1.1 to 4.2.1 using Git

by Ken Task -
Picture of Particularly helpful Moodlers
Below requires come command line foo and install of moosh.

Login to your moodle as admin level.
Navigate to Plugins Additional Plugins
admin/plugins.php?updatesonly=0&contribonly=1
Below each plugin you will see a 'shortname'
Copy and paste the shortname to a text file called 'addons.txt'.
Each addon on a separate line.
That file resides at the root of your moodle code.

After you have moosh installed, one can create a bash shell script called 'checkaddons' .... here's what that looks like:

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

You don't have to make the checkaddons script executable, could run it with:
source ./checkaddons

You have to have those in moodle code root because moosh will only do it's thing inside moodle code directory.

Output of running script looks like this:

source ./checkaddons
Add-on listing:
block_configurable_reports

---------------------
Addon in que: block_configurable_reports
block_configurable_reports,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.10,3.11,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,https://moodle.org/plugins/download.php/22758/block_configurable_reports_moodle311_2020110300.zip

In the above example pretty easy to tell ... configurable reports is a block.
Theme would be in themes.   Mods would be in mod. etc.

'SoS', Ken


Average of ratings: Useful (2)
In reply to Trapline Jams

Re: New to upgrading 4.1.1 to 4.2.1 using Git

by Ken Task -
Picture of Particularly helpful Moodlers
Bofore you begin below, make a backup of what code you have and a database dump.   moodledata won't change much.

If your original install wasn't using/with git, then the code directory doesn't have the hidden .git directory and hidden .gitfiles.

So what you have to do now ... if it's not really messed up ... is what has been tagged as a 'side load' of git from a git acquired code directory.

Basically ...
original code is in /var/www/html/ - you can see a config.php file there and a version.php file.   See what version you do have there:
fgrep '$release' version.php - let's hope it's still 4.1.x.

The side load:
cd /var/www/ note that's where you can see the html directory.
Git
git clone git://git.moodle.org/moodle.git htmlgit
That will create a directory htmlgit
cd htmlgit
git branch --track MOODLE_401_STABLE origin/MOODLE_401_STABLE
git checkout MOODLE_401_STABLE

The above commands should aquire version 4.1.highest of moodle code.
To check ... still in /var/www/htmlgit
fgrep '$release' version.php

See 4.1.highest?

Then next step ... the side load ...

Still in /var/www/htmlgit/
cp -rp .git ../html/ - note the dot in front of git ... and note ../ means up-one-level
cp -rp .github ../html/
cp -p .gitattributes ../html/
cp -p .gitignore

Ok, we are done copying the hidden git stuff.

Now check: cd /var/www/html/
ls -l .git*

Do you see the 2 directories and .git files?

Ok, good.

Don't skip this one:

git reset --hard

We now check to see what git is pointed to:

git branch -a

The * at the top should be next to * MOODLE_401_STABLE

check version:
fgrep '$release' version.php

Should see the highest of 4.1.x+ with a build date.

If we see that, we are a go.

Still in /var/www/html/
php admin/cli/maintenance.php --enable
php admin/cli/upgrade.php
you will see tables being updated.
When it finishes, take site out of maintenance mode
php admin/cli/maintenance.php --disable

Check ownerships/permissions on config.php ...
*must be readable by the globe.

Let's check stuff ... still in /var/www/html/
php admin/cli/checks.php
That should return:
OK: All 'status' checks OK

Ok, now open browser and hit the site.
Login as admin level user.

First thing you need to do is go to Notifications
Plugins you have installed should be in need of updating.
Update plugins ... note you don't have to do all of them at once.
I am cautious ... I do one at a time.

I'd also listen to Mr. V!!!   4.1 is long term support .. 4.2 is not!

See you have gmail.com in profile, we might be able to do a google meet.
I'll send you a PM here on this system with info.

'SoS', Ken


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

Re: New to upgrading 4.1.1 to 4.2.1 using Git

by Trapline Jams -
[SOLVED] - Thank you very much for your help! You were even willing to meet on Google Meet and guide me through the process described in the post above. Very patient with a beginner like myself.
In reply to Trapline Jams

Re: New to upgrading 4.1.1 to 4.2.1 using Git

by Ken Task -
Picture of Particularly helpful Moodlers
Welcome!  There are 2 departments one must please ... HR (if you want your job) and Business (if you wanna get paid). [insider info] smile

'SoS', Ken
In reply to Ken Task

Re: New to upgrading 4.1.1 to 4.2.1 using Git

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Ken, for the curious others, pl. document what you did. When you have time, that is, which I find difficult to imagine.
wink
In reply to Visvanath Ratnaweera

Re: New to upgrading 4.1.1 to 4.2.1 using Git

by Ken Task -
Picture of Particularly helpful Moodlers
Will leave details to OP ... I wasn't taking notes about OP's system.

But, I should have included the running of checks.php in admin/cli/.  That would have caught the requirement for max_input_vars to 5000.

When one tries to write an FAQ or blog post or forum post about using Git to do a side load, one doesn't think that users would be using FTP to make edits to .ini files, etc.   Plus, OP's workstation OS being Windows, OP was using Putty - well known client for ssh on Windows - and it's behavior for copy and paste different then that oh say terminal MacOS or terminal in a panel.   Copy in Putty auto places in clipboard and to paste in terminal window, right click is all that one needs.

IF, however, one catches a CR/LF on the copy the paste executes without giving OP a chance to change a parameter in the command.   OP's code directory is /moodle/ and example I gave had /html/

My self, have always opened a local text document, pasted there first, and made changes there before using accurate copy (catching no CR/LF) so when I paste into a terminal it doesn't auto execute.   We used a text document so OP could increase size of font so I could see .. Putty window default black background with what looked to be on my end a shade of gray 10-12 font.

And, on OP's system there were 2 php.ini's.  1 for web and 1 for CLI.

Will above satisfy your curiosity?

'SoS', Ken

Average of ratings: Useful (1)