Upgrading from Moodle 3.11.6 to 4.0+ via Git

Upgrading from Moodle 3.11.6 to 4.0+ via Git

by Giancarlo Conte -
Number of replies: 10

Hello, I installed moodle 3.8 via git and over time I updated the installation with these two commands:
# git pull
# cp /dir/moodle/install /dir/production

i don't know git very well and now i need to upgrade to moodle 4.0 version. Using the commands above the update is not done.
I think it depends on some new branch or similar in git, but I couldn't figure out where I'm wrong even using the Docs.

A thousand thanks

Average of ratings: -
In reply to Giancarlo Conte

Re: Upgrading from Moodle 3.11.6 to 4.0+ via Git

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
With 'git pull' you walk along the same branch. To move to another branch, you need a new 'git branch ..' and a 'git checkout ..'. See (3) and (4) in https://docs.moodle.org/400/en/Git_for_Administrators#Obtaining_the_code_from_Git for rel. 4.0.
In reply to Visvanath Ratnaweera

Ri: Re: Upgrading from Moodle 3.11.6 to 4.0+ via Git

by Giancarlo Conte -
thanks.


I would need step by step instructions, as I have absolutely no idea what happens with each of those commands.

Sorry, but I don't know git and having a site in production I wouldn't want to do any damage
In reply to Giancarlo Conte

Re: Ri: Re: Upgrading from Moodle 3.11.6 to 4.0+ via Git

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Step 1. https://docs.moodle.org/400/en/Upgrading#Check_the_requirements

Ask for Step 2, if Step 1 is positive. If not get the environment cleared.
;-(

P.S. I see that a developer has tried in the Italian forum: Aggiornare Moodle 3.11 usando Git https://moodle.org/mod/forum/discuss.php?d=424546#p1709895. What was the problem?

In reply to Visvanath Ratnaweera

Ri: Re: Ri: Re: Upgrading from Moodle 3.11.6 to 4.0+ via Git

by Giancarlo Conte -
in that post they explained me how to update using #git pull. But now I have to switch branches and I'm not sure what I'm going to do.
The requirements are all there, I miss the upgrade step.

So I would do:
$ git branch -a
$ git branch --track MOODLE_400_STABLE origin / MOODLE_400_STABLE
$ git checkout MOODLE_400_STABLE
$ sudo git pull

But does this erase all changes, for example the favicon?
In reply to Giancarlo Conte

Ri: Re: Ri: Re: Upgrading from Moodle 3.11.6 to 4.0+ via Git

by Sergio Rabellino -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Ciao,
git pull it's a simpler command that binds a git fetch and a git merge in a single command.
So the fetch downloads the most recent repo updates and merge - as the verb represents, does a merge of your current repo and the remote one.
The merge strategy can vary, but usually, do not remove any added file that was not present in the remote repository and subsequently deleted, so your favicon should stay across git pulls.
You can get errors/problems if you changed some files and your changes conflict with the merge with the new code.
As golden rule, you should not change the files into a git repository if you would pull them without panic.
The favicon.ico - i.e. - could be stored elsewhere and you can point to it by adding an Alias rule in your apache configuration (the same can be done with nginx).

In reply to Giancarlo Conte

Re: Ri: Re: Ri: Re: Upgrading from Moodle 3.11.6 to 4.0+ via Git

by Ken Task -
Picture of Particularly helpful Moodlers

git will update files that need updating ... not entire file but the parts/pieces.  It will also remove/delete files no longer needed as well as add files that are needed.

When using git pull to update a site, the output should show something like this (this is a 3.10 but any version should show similar):

Fast-forward
 admin/tool/customlang/locallib.php                             | 17 +++++++++--
 .../task/send_mnet_profiles_data_removed_notification.php      | 45 +++++++++++++++++++++++++++++
 admin/tool/moodlenet/db/upgrade.php                            | 19 ++++++++++++
 admin/tool/moodlenet/lang/en/tool_moodlenet.php                | 15 ++++++----
 admin/tool/moodlenet/version.php                               |  2 +-
 install/lang/my/error.php                                      |  1 +
 install/lang/my/moodle.php                                     |  1 +
 install/lang/sk/error.php                                      |  3 +-
 lang/en/user.php                                               |  4 +--
 lib/mlbackend/python/classes/processor.php                     |  2 +-
 version.php                                                    |  4 +--
 11 files changed, 98 insertions(+), 15 deletions(-)

You can see above the  file:

 admin/tool/moodlenet/db/upgrade.php had the most change ... 45

At the very end before the summary, on should always see that last line ... version.php and from what I've observed it's always 4 +--

And to verify it's the version you expect, one could issue:

fgrep '$release' version.php

from the root of the code directory

You could finish the update via:

php admin/cli/upgrade.php --non-interactive

That upgrades the DB tables.

In this example:

-->System
++ Success (0.69 seconds) ++
-->tool_moodlenet

and the last thing that it does is:

== Setting new default values ==

That last step usually has a long pause ... so don't get nervous! smile

then take site out of maintenance mode:

php admin/cli/maintenance.php --disable

and while there ... run cron with

php admin/cli/cron.php

and then also purge the caches

php admin/cli/purge_caches.php

Then check the site with graphical.

All in all - git is by far the best way to update or upgrade a moodle!

'SoS', Ken

In reply to Giancarlo Conte

Re: Upgrading from Moodle 3.11.6 to 4.0+ via Git

by Ken Task -
Picture of Particularly helpful Moodlers

Know this response isn't really answering the question, but, think it wise to advise doing environment check before hyperjumping a moodle upgrade.

Also, consider this .. the next long term support version for moodle is 4.1 ... not 4.0.  Is there any compelling reason to upgrade to 4.0 at this time?   Your version 3.11.6 is supported for some time:

Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).

https://docs.moodle.org/dev/Releases#Moodle_3.11
'SoS', Ken

In reply to Ken Task

Ri: Re: Upgrading from Moodle 3.11.6 to 4.0+ via Git

by Giancarlo Conte -
this is true but I am trying to carry on, considering that unfortunately I know very little about git