Upgrading using Git

Upgrading using Git

by Miguel Fabo -
Number of replies: 9
Hi Ken, I'm sorry to bother you. In my work we're running Moodle 3.2.9 and at the end of this year we want to migrate to a new hosting company and update to Moodle 4, refresh how our platform looks, etc. So far we update Moodle in the old way, that is, replacing the files via FTP. But I'd like to learn how to do it using Git as I have read a lot about its benefits. The problem is that I've read the official documentation several times and find it very confusing. Investigating a little I saw this thread, and I wanted to ask you what you suggest. Do you have any idea if there is a step-by-step guide on how to use Git with Moodle? I have many months ahead of me and I'd like to learn and practice. Thank you very much in advance!
Average of ratings: -
In reply to Miguel Fabo

Re: Can't upgrade because new version of PHP not recognized

by Ken Task -
Picture of Particularly helpful Moodlers

@Migel ... Let's not forget Howard and Leon.

And don't forget Mr. V's blog:

http://www.syndrega.ch/blog/#php-and-dbms-compatibility-of-major-moodle-releases

Leon recently helped in another discussion @ https://moodle.org/mod/forum/discuss.php?d=419869#p1692113

which is very similar to side loading a git acquired code directory then copying the hidden .git directory and hidden .gitx files to an active site to get the active site under git.  Actually, Leon's method looks to be equal to or even better than sideload/.git copy to active site.

Because you are learning, best to work on a clone of your current site.

Step by step guide dependent upon many factors ... one of those is 'clas' (command line avoidance syndrome) .. .if you suffer from that, then ... get over it! smile

Official Docs to read and study:

https://docs.moodle.org/310/en/Git_for_Administrators

Do check Site Admin, Server, Environment and update component.   Then select higher versions of Moodle in the drop down to see what Moodle says about your environment.

Make a map of when you will pull the trigger on upgrading PHP/MySQL/MariaDB prior to the next moodle version hop.

I, for one, prefer to 'march' (one version up at a time) as opposed to hyper jumps.   Find one experiences fewer catch 22's and 'gotcha's' that way.  Don't forget ... themes and old no longer supported plugins can bite and some you might be using might need to go.

For the last couple of weeks have been attempting to assist a person on shared hosting (shdh) get squared away.   So when moving to a new hosting provider, don't jump out of the pan into the fire.  shdh -> shdh still lands one in a user jail and caps/restrictions.   Best to move to a VPS where there are no other customers.   BTW, if new hosting VPS offers WHM/cPanel on a VPS ... I'd not do it ... one step in right direction, but 2 steps back with WHM/cPanel, IMHO!  'Panel' that I think is much better ... Webmin.

That a start for ya?

'SoS', Ken

In reply to Ken Task

Re: Can't upgrade because new version of PHP not recognized

by Miguel Fabo -

Hi Ken, thank you very much for your answer and for all the information you shared with me, I think you clarified all my doubts. From what I see there are a lot of things to consider before I get down to business, so I think I found some reading material to entertain myself this weekend haha. The reason for wanting to change our hosting company is the lousy technical support and that they migrated our two websites (a domain that was developed on Joomla and a subdomain that runs Moodle) from one server to another, breaking both sites in the process, twice. In one month. And at no time did they take responsibility for the damage caused. But I'll take into account everything you mentioned before making that move. I'm still fixing errors that pop up here and there. And it's annoying because both sites worked perfectñy before.

As for plugins and themes, yes, the theme that is currently used is Essential, and I read that they no longer develop it. But I will take the opportunity to upgrade Moodle and refresh the look of the site with a different theme, so there are no problems.

Again, thank you very much for your response and this weekend I will take the time to read everything. For now, I will practice what I learn on my PC, through Xampp. Have a great weekend, and thank you very much again!

Ps: that PHP and DBMS compatibility table will save my life haha.

In reply to Miguel Fabo

Re: Can't upgrade because new version of PHP not recognized

by Ken Task -
Picture of Particularly helpful Moodlers

Welcome.  Credit where credit is due ... that PHP/DB chart is Mr. V's! smile

Howard shared the idea of a git sideload ... and Leon's latest advice is just as good!   So thanks, guys!

About your plan to use Windows as testing platform ... if one looks at what will be the production environment (typically linux) things like git is more native to Linux than Windows ... same is true of apache/nginx/mysql/mariadb and other things ... like bash shell scripts (I have such scripts and use them to 'march moodles' via git)

Since you have plenty of time and you appear to be savy enough, suggest using VirtualBox and OSboxes.

https://www.virtualbox.org/
https://www.osboxes.org/virtualbox-images/

If you know the production system is a Ubuntu LTS 20.x *uname -an*

then in your VB/OSbox set up get that!  Now you are learning what it will be like in the production environment.

Example of a 'bu' and a 'up' script placed in code root and then seen/executed only by root user of server (even if I share here, anyone with browser cannot view ... even if they figure out the URL to it!)

-rwx------. 1 root root 861 Jan 30 12:59 up

ditto ownerships/permissions on bu.

bu

# 3.8.8+ (Build: 20210312)
tar -cvf /mnt/data/backup/m38/moodle-code-388+-$(date +%Y%m%d%-H%M%S).tar ../moodle38;
tar -cvf /mnt/data/backup/m38/moodle-data-min-388+-$(date +%Y%m%d%-H%M%S).tar /var/www/moodle38data/filedir;
mysqldump -u root -p'[password]' moodle38 > /mnt/data/backup/m38/moodle388+-db-$(date +%Y%m%d%-H%M%S).sql;
ls -l /mnt/data/backup/m38/;

The backup location on a mounted device for storage.

up

echo '3.8.7 (Build: 20210118)'
git branch -a
php admin/cli/cron.php;
php admin/cli/maintenance.php --enable;
git pull;
php admin/cli/upgrade.php --non-interactive;
php admin/cli/maintenance.php --disable;
chown apache:apache * -R;
chown root:root up bu;
fgrep '$release' version.php

How would you do those (bu and up) on Windows?

'SoS', Ken

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

Re: Upgrading using Git

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

Mr V's (mark-down) table. smile

A complete tutorial on VirtualBox and Linux (CentOS, Debian, Ubuntu) would be nice. Here is a well-worn attempt: https://moodle.org/mod/forum/discuss.php?d=199542.

Who can recommend a good tutorial on "side-loading" a zip installed Moodle site (a generic one for the community)?

In reply to Visvanath Ratnaweera

Re: Upgrading using Git

by Ken Task -
Picture of Particularly helpful Moodlers

Sideload tutorial ... confused .... what I was referring to was a site not installed with git, sideloading same major version (example a 3.5.x) via git, and then copying the hidden .git directory and other .git files into active moodle.

Let's say a shared hosting customer has terminal (cPanel icon) and their moodle code resides in /home/customername/public_html/

Sideload:

in /home/customername/

git clone git://git.moodle.org/moodle.git public_htmlgit

cd public_htmlgit

git branch --track MOODLE_35_STABLE origin/MOODLE_35_STABLE

git checkout MOODLE_35_STABLE

fgrep '$release' version.php

cp -rp .git ../public_html/
cp -rp .github ../public_html/
cp -p .gherkin-lintrc .gitattributes .gitignore ../public_html/

cd ../public_html/

git branch -a (q to quit)

a git pull should trigger an update to a 3.5.lowerthanhighest code.

If it doesn't: git reset --hard

and try git pull again

Finish with

cd admin/cli/

php upgrade.php

while one is in admin/cli/ may as well:

php purge_caches.php

php cron.php

Check GUI site.

Backup site! smile

public_htmlgit directory no longer needed and can be removed.

That's public_htmlgit .... repeat ... public_htmlgit

Only acquires core.

'SoS',


In reply to Ken Task

Re: Upgrading using Git

by Ken Task -
Picture of Particularly helpful Moodlers

Ooops! Some prelim if on shared hosting cPanel ...

In cPanel one sees a Terminal icon/button ... which when clicked brings up a terminal window (big black square) and user is in their /home/username/ directory.

In cPanel there is an icon/button for a Git Repository.

IF your cPanel doesn't have Terminal or Git Repo icon/button, ask provider helpdesk to install it for you ...  but don't be surprised IF they say they don't offer it for your 'extremely affordable' setup! :|

Without those 2 being present, my sideload description above is just a 'wonder if'!

'SoS', Ken

In reply to Ken Task

Re: Upgrading using Git

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

What I meant with "side-loading a zip installed Moodle site" is how somebody who already runs a Moodle site in which the code directory either has not Git connection or the Git repo is broken, could repair/restart on code which is Git-clean. Oh, yes, on the Unix CLI.

I have seen parts of it explained in different forum posts. A summarizing how-to would be nice. Not that I have a case, more as a reference for others.
In reply to Visvanath Ratnaweera

Re: Upgrading using Git

by Ken Task -
Picture of Particularly helpful Moodlers

By zip, guessing you mean Windows platform.
I've always thought it 'strange' that Moodle Downloads has
available for download a .tgz archive (54.8MB) and a .zip (71.3MB).
Reason?  Compression?  No, it's platform specific stuff.

Kens-MBP-2:moodle kentask$ find ./ -name \*.exe
.//filter/tex/mimetex.exe

find ./ -name \*mime\*
.//filter/tex/mimetex.freebsd
.//filter/tex/mimetex.linux
.//filter/tex/mimetex.exe
.//filter/tex/README.mimetex
.//filter/tex/mimetex.darwin

A downloaded zip archive unzipped on a Mac:

Kens-MBP-2:moodle kentask$ du -h .//filter/tex/mimetex.exe
1.3M    .//filter/tex/mimetex.exe

Kens-MBP-2:moodle kentask$ du -h .//filter/tex/mimetex.linux
1.3M    .//filter/tex/mimetex.linux
Kens-MBP-2:moodle kentask$ du -h .//filter/tex/mimetex.freebsd
1.3M    .//filter/tex/mimetex.freebsd
Kens-MBP-2:moodle kentask$ du -h .//filter/tex/mimetex.darwin
2.7M    .//filter/tex/mimetex.darwin

https://en.wikipedia.org/wiki/Darwin_(operating_system)

Guess it's related to conflicting advice (to me at least) seen here in forums ...
'best for the job' vs 'use that which one is familiar'.

Thought 'educating'/learning was all about something you don't know, but probably should - any 'body of knowledge' ... including tech.

So no ... don't have any good advice concerning maintaining core code for the situation you've described - cept one ... use what's best for the job ... and in MHO, that's Linux! smile

'SoS', Ken

Average of ratings: Useful (1)
In reply to Miguel Fabo

Re: Upgrading using Git

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Miguel,

Just to let you know I have split your post from the discussion 'Can't upgrade because new version of PHP not recognized' and given it a new title 'Upgrading using Git'.