Updating Question

Updating Question

by Michael Knichel -
Number of replies: 17

If I installed moodle on my production sever by copying files from my dev server, can I switch to using git on the production server?  

I used git on my dev server after copying files to production sever to start fresh.  I am just wondering what will happen to the current install on my production server if I use git to perform the update?


MK

Average of ratings: -
In reply to Michael Knichel

Re: Updating Question

by Ken Task -
Picture of Particularly helpful Moodlers

Check production server environment ... php version,php extensions and full compliance with Innodb + utf8b4 (character set/collation)

When you copied the code directory to the production server that should have included the hidden .git directory.  Did you copy that way?  

If production server supports git and no git ports are blocked by network restrictions, one could ssh into production server, cd to code directory, and as a test, type:

git branch -a

If you are on shared hosting there could be issues.

'SoS', Ken

In reply to Ken Task

Re: Updating Question

by Michael Knichel -
So the .git folder is not on the server. Can I copy it from the dev server? or original archive?\

version.php on production server...
$version  = 2020061501.10;              // 20200615      = branching date YYYYMMDD - do not modify!
                                       //         RR    = release increments - 00 in DEV branches.
                                       //           .XX = incremental changes.
$release  = '3.9.1+ (Build: 20200822)'; // Human-friendly version name
$branch   = '39';                       // This version's branch.
$maturity = MATURITY_STABLE;             // This version's maturity level.

version.php on dev server...
defined('MOODLE_INTERNAL') || die();

$version  = 2020061501.14;              // 20200615      = branching date YYYYMMDD - do not modify!
                                        //         RR    = release increments - 00 in DEV branches.
                                        //           .XX = incremental changes.
$release  = '3.9.1+ (Build: 20200910)'; // Human-friendly version name
$branch   = '39';                       // This version's branch.
$maturity = MATURITY_STABLE;             // This version's maturity level.

I must have removed my original archive... sad

Oh, and I *am* on shared hosting... How will I know if this is a problem?
Thanks for your help.


In reply to Michael Knichel

Re: Updating Question

by Ken Task -
Picture of Particularly helpful Moodlers

Please, check production server environment.  On shared hosting it means shared DB servers also.   The requirements for moodle DB full compliance with InnoDB and utf8mb4 is the issue.   DB server must support.

"Oh, and I *am* on shared hosting... How will I know if this is a problem?"

Shared hosting folks usually have a control panel of some sort ... cPanel?

Does it have a git icon?

Also, to update or upgrade the moodle code via git in your user space on the production server, you'll have to have ssh (command line access) to your account on that shared system and that account would need access to the git binary ... typically in /usr/bin/git.

Quick test after you upload the hidden .git files/directory:

drwxr-xr-x   15 kentask  staff       480 Sep 23 06:36 .git
-rw-r--r--    1 kentask  staff        94 Jun 15 07:23 .gitattributes
drwxr-xr-x    3 kentask  staff        96 Jun 15 07:23 .github
-rw-r--r--    1 kentask  staff      1071 Jun 15 07:23 .gitignore

test

from code directory and via ssh:

git branch -a

to see if you can exeute.

backup code and db of site, again ..  backup code and db of site ... 

minimal backup ... config.php ... that is really the most important.  And any addon/plugins you've installed on production site.

then one could try a:

git pull

It's with that where you might run into issues using git on shared hosting + if shared hosting supports DB - not just the version ... but collation/character sets, etc.

'SoS', Ken


In reply to Ken Task

Re: Updating Question

by Michael Knichel -
Thanks for the info. I will try this as soon as I get some free time and the site is not in use...

MK
In reply to Ken Task

Re: Updating Question

by Michael Knichel -
So I hit a snag. My dev version that has the .git folder is 3.8 where my production is 3.9.1+. My dev version that is 3.9.1 doesn't have a .git folder for some reason, only the .github... strange.
I question is can I copy the .git & .githup folders form the 3.8 version to my production server if the production is already at 3.9.1?
OR
Should I just copy the directory from my dev server up to the production server and continue future upgrades using git?

MK
In reply to Michael Knichel

Re: Updating Question

by Ken Task -
Picture of Particularly helpful Moodlers

No .git directory means it wasn't installed via git but other.

Thought you said production and dev were same version?

Get your dev to 3.9.highest to match major version you have on server.  That's major version ... not point release ... moodle releases code every week.

Currently (today):
fgrep '$release' version.php
$release  = '3.9.2+ (Build: 20200924)'; // Human-friendly version name

upload the hidden .git directory and other hidden .git files to production server.

ssh into production server

cd to code

git reset --hard

Check branch git branch -a

now do a git pull

should result ... if you have not edited core files ... in an update to
3.9.2+ (Build: 20200924)

While you are there ... cd admin/cli/
php upgrade.php

Takes web server out of the loop.

Do have a backup of code and DB before playing! smile
'SoS', Ken

In reply to Ken Task

Re: Updating Question

by Ken Task -
Picture of Particularly helpful Moodlers

Update ... same version like 3.8.1  this for point releases to 3.8.highest.

Do backup of code and DB

git branch -a
php admin/cli/cron.php;
php admin/cli/maintenance.php --enable;
git pull;
php admin/cli/upgrade.php --non-interactive;

check ownerships/permissions

*upgrade*  If @ 3.8.highest and want 3.9.x

Do backup of code and DB

php admin/cli/cron.php;
php admin/cli/maintenance.php --enable;
git branch --track MOODLE_39_STABLE origin/MOODLE_39_STABLE
git checkout MOODLE_39_STABLE
php admin/cli/upgrade.php --non-interactive;
php admin/cli/maintenance.php --disable;

Check version fgrep '$release' version.php

Consider purging caches while there ...

php admin/cli/purge_caches.php

'SoS', Ken


In reply to Ken Task

Re: Updating Question

by Michael Knichel -
I really appreciate your help.
The problem (I think) is that my production server doesn't have a .git folder (moodle version 3.9.1+ (Build: 20200822)).  I copied from my dev server and didn't get the hidden folders.  Since then I have used git to upgrade my dev server so I don't have the .git folder that goes with the version on my server (moodle version 3.9.2 (Build: 20200914)).

Could/should I copy the .git folder (and other git files) from a 3.9.? install over and try those commands??  I am unable to locate a download for the exact build that I have.  I am a git noob, so I don't want to render my site unusable.

MK
In reply to Michael Knichel

Re: Updating Question

by Michael Knichel -
OR is there a way to start over? I have classes set up in moodle already. I have not collected student work as of yet. Could I export the classes from the db and install moodle on both servers using git then import the classes? Wondering if that is just going to be the simpler route...

MK
In reply to Michael Knichel

Re: Updating Question

by Ken Task -
Picture of Particularly helpful Moodlers

Your dev server is/was a 3.9.x?

Your production server is a 3.9.x?   It has students in it and active.

Yes ... restoring course backups might be easiest at this point .... considering experience.

On the production server install it with git.

If you didn't install it with git, use the 'side load' method of acquiring the hidden .git directory files (kinda described already in this thread).

Run the git pull on production server ... and assure it updates ok to highest version of 3.9.x and that everything functions.

On your dev server, make the course backups ... no users.   Do just one.

Then test restore of that one course to your production server.

And it is advised to make site backups ... code + DB dump + minimal moodledata/filedir/ and know how to restore, before side load or any other major change.

'SoS', Ken

In reply to Ken Task

Re: Updating Question

by Michael Knichel -
OK, let me see if I understand all of this...

As long as the dev and prod servers are both 3.9.(whatever)...
1) upgrade dev server to highest 3.9 possible
2) copy the .git (and other git files) to the server
On prod server in moodle code dir:
3) git reset --hard
4) git pull
5) php admin/cli/upgrade.php
6) test and pray...

Of course I will backup the code dir, data dir and sqlDB first.

I would prefer to upgrade in place if I can since I don't know how to backup users with passwords etc. and backing up all of the courses will take some time.
In reply to Michael Knichel

Re: Updating Question

by Ken Task -
Picture of Particularly helpful Moodlers

That sounds right ... however, potentially ... big catch 22!

On shared hosting you have limits i/o, space, memory, tweaks .. like how often one can run cron and how much of shared resources a cron job like autobackups can consume, etc.  + bigger than that ... tweaks to db server config ... will come into play when backing up or restoring large course backups - max_allowed_packets - open files - innodb utf8mb4 character set and collation ... to name a few.

* Do run Moodle admin -> Server -> Environment.   Update the component ... and let's see/check on some things.

Things you won't see ... DB maxes.

'SoS', Ken


In reply to Ken Task

Re: Updating Question

by Michael Knichel -
I ran the update component and it returned Component Installed. The only item in the environment not green is:
php_setting opcache.enable
PHP setting should be changed.
PHP opcode caching improves performance and lowers memory requirements, OPcache extension is recommended and fully supported.

I haven't figured this one out yet. Everything else is green.

Server checks

NameInformationReportPluginStatus
php_settingopcache.enable

PHP opcode caching improves performance and lowers memory requirements, OPcache extension is recommended and fully supported.

Check
moodleOK
unicodeOK
databasemysql (5.7.23-23)OK
phpOK
pcreunicodeOK
php_extensioniconvOK
php_extensionmbstringOK
php_extensioncurlOK
php_extensionopensslOK
php_extensiontokenizerOK
php_extensionxmlrpcOK
php_extensionsoapOK
php_extensionctypeOK
php_extensionzipOK
php_extensionzlibOK
php_extensiongdOK
php_extensionsimplexmlOK
php_extensionsplOK
php_extensionpcreOK
php_extensiondomOK
php_extensionxmlOK
php_extensionxmlreaderOK
php_extensionintlOK
php_extensionjsonOK
php_extensionhashOK
php_extensionfileinfoOK
php_settingmemory_limitOK
php_settingfile_uploadsOK

In reply to Ken Task

Re: Updating Question

by Michael Knichel -
Ken,
Thank you for your help. Today I performed a test on my dev server by copying everything from my Prod server to my Dev server and rand the steps above. It all worked out so I ran on Prod sever and my prod server is now up to date. I appreciate the detail and patience you provided me.
MK
In reply to Michael Knichel

Re: Updating Question

by Ken Task -
Picture of Particularly helpful Moodlers

Welcome and Congrats!   Think you'll find it easier to keep your Moodle up-to-date now.   Just make sure - dev first testing via git.   No need to upload dev to prod any more as long as git works.

'SoS', Ken


In reply to Ken Task

Re: Updating Question

by Michael Knichel -
I got a notification about upgrade so I thought I would see if I can upgrade now that both dev/prod match.
Based on the docs, it says all I have to do is "git pull" from my moodle install directory. I did that and see lots of files with changes. When I go to the web interface, I was presented with the "Checks" and all was green. I went through the prompts to complete the process and now I am presented with "There is a newer version ... 3.9.3+".

I was on 3.9.2+ so I went back to CLI and ran git pull again and it says that I am Already up to date.

What am I missing here?

MK
In reply to Ken Task

Re: Updating Question

by Michael Knichel -

OK, so I ran a test...

/var/www/html/moodle$ git branch -a

* MOODLE_38_STABLE

  master

  remotes/origin/HEAD -> origin/master

  remotes/origin/MOODLE_13_STABLE

  remotes/origin/MOODLE_14_STABLE

...

  remotes/origin/MOODLE_37_STABLE

  remotes/origin/MOODLE_38_STABLE

:

The git pull gave me this:

/var/www/html/moodle$ git pull

remote: Counting objects: 15237, done.

remote: Compressing objects: 100% (5145/5145), done.

remote: Total 15237 (delta 10220), reused 13243 (delta 9697)

Receiving objects: 100% (15237/15237), 8.80 MiB | 8.67 MiB/s, done.

Resolving deltas: 100% (10220/10220), done.

From git://git.moodle.org/moodle

   bbc79e490a7..99b17429618  MOODLE_38_STABLE  -> origin/MOODLE_38_STABLE

 * [new branch]              MOODLE_310_STABLE -> origin/MOODLE_310_STABLE

   66041145712..598064e4d99  MOODLE_35_STABLE  -> origin/MOODLE_35_STABLE

   868f9fa5bdd..f6e37fe1953  MOODLE_37_STABLE  -> origin/MOODLE_37_STABLE

 * [new branch]              MOODLE_39_STABLE  -> origin/MOODLE_39_STABLE

   71a34a039fd..5486b031eeb  master            -> origin/master

 * [new tag]                 v3.5.14           -> v3.5.14

 * [new tag]                 v3.7.8            -> v3.7.8

 * [new tag]                 v3.5.13           -> v3.5.13

 * [new tag]                 v3.7.7            -> v3.7.7

 * [new tag]                 v3.8.4            -> v3.8.4

 * [new tag]                 v3.8.5            -> v3.8.5

 * [new tag]                 v3.9.0            -> v3.9.0

 * [new tag]                 v3.9.0-rc2        -> v3.9.0-rc2

 * [new tag]                 v3.9.0-rc3        -> v3.9.0-rc3

 * [new tag]                 v3.9.1            -> v3.9.1

 * [new tag]                 v3.9.2            -> v3.9.2

Updating bbc79e490a7..99b17429618

error: Your local changes to the following files would be overwritten by merge:

        admin/cli/install.php

        admin/environment.xml

<output omitted>

        lib/adminlib.php

        lib/amd/bu

error: The following untracked working tree files would be overwritten by merge:

        admin/tool/usertours/pix/t/filler.png

        completion/tests/behat/completion_other_courses.feature

        <output omitted>

        pix/t/uplong.png

        pix/t/uplong.svg

Please move or remove them before you merge.

Aborting