Caprover upgrade fail

Caprover upgrade fail

by Barking Bandicoot -
Number of replies: 8

I used these Bitnami instructions to upgrade Moodle for my Caprover (Docker) system from V5.3.1 to 5.3.3.

This method has worked previously numerous times yet has now failed.

I get a loop when after it prints: Running database upgrade


2025-03-20T22:26:10.960122801Z moodle 22:26:10.95 INFO  ==> 
2025-03-20T22:26:10.966781094Z moodle 22:26:10.96 INFO  ==> Welcome to the Bitnami moodle container
2025-03-20T22:26:10.967816489Z moodle 22:26:10.96 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
2025-03-20T22:26:10.970035633Z moodle 22:26:10.96 INFO  ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
2025-03-20T22:26:10.972668187Z moodle 22:26:10.97 INFO  ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
2025-03-20T22:26:10.974745012Z moodle 22:26:10.97 INFO  ==> 
2025-03-20T22:26:10.976501193Z moodle 22:26:10.97 INFO  ==> ** Starting Moodle setup **
2025-03-20T22:26:11.034881626Z moodle 22:26:11.03 INFO  ==> Generating sample certificates
2025-03-20T22:26:12.251341980Z Certificate request self-signature ok
2025-03-20T22:26:12.251404657Z subject=CN = example.com
2025-03-20T22:26:12.289101535Z realpath: /bitnami/apache/conf: No such file or directory
2025-03-20T22:26:12.295185796Z moodle 22:26:12.29 INFO  ==> Configuring Apache ServerTokens directive
2025-03-20T22:26:12.339340524Z moodle 22:26:12.33 INFO  ==> Configuring PHP options
2025-03-20T22:26:12.353281581Z moodle 22:26:12.35 INFO  ==> Setting PHP expose_php option
2025-03-20T22:26:12.369399719Z moodle 22:26:12.36 INFO  ==> Setting PHP max_execution_time option
2025-03-20T22:26:12.383632076Z moodle 22:26:12.38 INFO  ==> Setting PHP max_input_time option
2025-03-20T22:26:12.399288590Z moodle 22:26:12.39 INFO  ==> Setting PHP max_input_vars option
2025-03-20T22:26:12.414325998Z moodle 22:26:12.41 INFO  ==> Setting PHP memory_limit option
2025-03-20T22:26:12.426537146Z moodle 22:26:12.42 INFO  ==> Setting PHP post_max_size option
2025-03-20T22:26:12.441931728Z moodle 22:26:12.44 INFO  ==> Setting PHP upload_max_filesize option
2025-03-20T22:26:12.453815129Z moodle 22:26:12.45 INFO  ==> Setting PHP output_buffering option
2025-03-20T22:26:12.486524258Z moodle 22:26:12.48 INFO  ==> Validating settings in MYSQL_CLIENT_* env vars
2025-03-20T22:26:12.496130787Z moodle 22:26:12.49 INFO  ==> Validating settings in POSTGRESQL_CLIENT_* env vars
2025-03-20T22:26:12.632631421Z moodle 22:26:12.63 INFO  ==> Restoring persisted Moodle installation
2025-03-20T22:26:15.393394552Z moodle 22:26:15.39 INFO  ==> Trying to connect to the database server
2025-03-20T22:26:15.472767014Z moodle 22:26:15.47 INFO  ==> Running database upgrade

Moodle directory permissions

Are the following permissions correct or incorrect for my Moodle directory?: ls -la
total 1276
drwxrwxr-x 65 daemon   daemon     4096 Feb 10 03:32 .
drwxr-xr-x  6 barkingb barkingb   4096 Mar 20 22:43 ..
drwxrwxr-x 16 daemon   daemon     4096 Feb  7 13:18 admin
drwxrwxr-x  8 daemon   daemon     4096 Feb  7 13:18 ai
drwxrwxr-x  5 daemon   daemon     4096 Feb  7 13:18 analytics
drwxrwxr-x 16 daemon   daemon     4096 Feb  7 13:18 auth
drwxrwxr-x  8 daemon   daemon     4096 Feb  7 13:18 availability
drwxrwxr-x  8 daemon   daemon     4096 Feb  7 13:18 backup
drwxrwxr-x  8 daemon   daemon     4096 Feb  7 13:18 badges
-rw-rw-r--  1 daemon   daemon      311 Feb  7 13:18 behat.yml.dist
drwxrwxr-x 48 daemon   daemon     4096 Feb  7 13:18 blocks
drwxrwxr-x  4 daemon   daemon     4096 Feb  7 13:18 blog
-rw-rw-r--  1 daemon   daemon     1162 Feb  7 13:18 brokenfile.php
drwxrwxr-x  7 daemon   daemon     4096 Feb  7 13:18 cache
drwxrwxr-x  7 daemon   daemon     4096 Feb  7 13:18 calendar
drwxrwxr-x  5 daemon   daemon     4096 Feb  7 13:18 cohort
drwxrwxr-x  5 daemon   daemon     4096 Feb  7 13:18 comment
drwxrwxr-x  6 daemon   daemon     4096 Feb  7 13:18 communication
drwxrwxr-x  4 daemon   daemon     4096 Feb  7 13:18 competency
drwxrwxr-x  5 daemon   daemon     4096 Feb  7 13:18 completion
-rw-rw-r--  1 daemon   daemon     2094 Feb  7 13:18 composer.json
-rw-rw-r--  1 daemon   daemon   168233 Feb  7 13:18 composer.lock
-rw-rw-r--  1 daemon   daemon    68644 Feb  7 13:18 config-dist.php
-rw-r-----  1 root     daemon      986 Dec 22  2023 config.php
drwxrwxr-x  7 daemon   daemon     4096 Feb  7 13:18 contentbank
-rw-rw-r--  1 daemon   daemon     2651 Feb  7 13:18 CONTRIBUTING.md
-rw-rw-r--  1 daemon   daemon    35147 Feb  7 13:18 COPYING.txt
drwxrwxr-x 10 daemon   daemon     4096 Feb  7 13:18 course
drwxrwxr-x  7 daemon   daemon     4096 Feb  7 13:18 customfield
drwxrwxr-x  8 daemon   daemon     4096 Feb  7 13:18 dataformat
-rw-rw-r--  1 daemon   daemon     2675 Feb  7 13:18 draftfile.php
-rw-rw-r--  1 daemon   daemon     1382 Feb  7 13:18 editmode.php
drwxrwxr-x 19 daemon   daemon     4096 Feb  7 13:18 enrol
drwxrwxr-x  2 daemon   daemon     4096 Feb  7 13:18 error
-rw-rw-r--  1 daemon   daemon     8426 Feb  7 13:18 .eslintrc
drwxrwxr-x  4 daemon   daemon     4096 Feb  7 13:18 favourites
-rw-rw-r--  1 daemon   daemon     3919 Feb  7 13:18 file.php
drwxrwxr-x  5 daemon   daemon     4096 Feb  7 13:18 files
drwxrwxr-x 18 daemon   daemon     4096 Feb  7 13:18 filter
-rw-rw-r--  1 daemon   daemon      597 Feb  7 13:18 .gherkin-lintrc
-rw-rw-r--  1 daemon   daemon      142 Feb  7 13:18 .gitattributes
-rw-rw-r--  1 daemon   daemon      953 Feb  7 14:42 githash.php
drwxrwxr-x  3 daemon   daemon     4096 Feb  7 13:18 .github
drwxrwxr-x 11 daemon   daemon     4096 Feb  7 13:18 grade
drwxrwxr-x  6 daemon   daemon     4096 Feb  7 13:18 group
drwxrwxr-x  5 daemon   daemon     4096 Feb  7 13:18 .grunt
-rw-rw-r--  1 daemon   daemon     9671 Feb  7 13:18 Gruntfile.js
drwxrwxr-x  9 daemon   daemon     4096 Feb  7 13:18 h5p
-rw-rw-r--  1 daemon   daemon     1423 Feb  7 13:18 help_ajax.php
-rw-rw-r--  1 daemon   daemon     1872 Feb  7 13:18 help.php
-rw-rw-r--  1 daemon   daemon     5435 Feb  7 13:18 index.php
drwxrwxr-x  3 daemon   daemon     4096 Feb  7 13:18 install
-rw-rw-r--  1 daemon   daemon    25849 Feb  7 13:18 install.php
-rw-rw-r--  1 daemon   daemon      664 Feb  7 13:18 INSTALL.txt
drwxrwxr-x  3 daemon   daemon     4096 Feb  7 13:18 iplookup
-rw-rw-r--  1 daemon   daemon       16 Feb  7 13:18 .jshintignore
-rw-rw-r--  1 daemon   daemon     1545 Feb  7 13:18 .jshintrc
drwxrwxr-x  3 daemon   daemon     4096 Feb  7 13:18 lang
drwxrwxr-x 75 daemon   daemon     4096 Feb  7 13:18 lib
drwxrwxr-x  2 daemon   daemon     4096 Feb  7 13:18 local
drwxrwxr-x  3 daemon   daemon     4096 Feb  7 13:18 login
drwxrwxr-x  4 daemon   daemon     4096 Feb  7 13:18 media
drwxrwxr-x  7 daemon   daemon     4096 Feb  7 13:18 message
drwxrwxr-x  6 daemon   daemon     4096 Feb  7 13:18 mnet
drwxrwxr-x 28 daemon   daemon     4096 Feb 10 03:43 mod
drwxrwxr-x  2 daemon   daemon     4096 Feb  7 13:18 moodlenet
drwxrwxr-x  5 daemon   daemon     4096 Feb  7 13:18 my
drwxrwxr-x  4 daemon   daemon     4096 Feb  7 13:18 notes
-rw-rw-r--  1 daemon   daemon   484761 Feb  7 13:18 npm-shrinkwrap.json
-rw-rw-r--  1 daemon   daemon        8 Feb  7 13:18 .nvmrc
-rw-rw-r--  1 daemon   daemon     1825 Feb  7 13:18 package.json
drwxrwxr-x  7 daemon   daemon     4096 Feb  7 13:18 payment
-rw-rw-r--  1 daemon   daemon      145 Feb  7 13:18 phpcs.xml.dist
drwxrwxr-x  2 daemon   daemon     4096 Feb  7 13:18 .phpstorm.meta.php
-rw-rw-r--  1 daemon   daemon    16002 Feb  7 13:18 phpunit.xml.dist
drwxrwxr-x 14 daemon   daemon     4096 Feb  7 13:18 pix
drwxrwxr-x  4 daemon   daemon     4096 Feb  7 13:18 plagiarism
-rw-rw-r--  1 daemon   daemon     1677 Feb  7 13:18 pluginfile.php
drwxrwxr-x  8 daemon   daemon     4096 Feb  7 13:18 portfolio
drwxrwxr-x  6 daemon   daemon     4096 Feb  7 13:18 privacy
drwxrwxr-x 12 daemon   daemon     4096 Feb  7 13:18 question
drwxrwxr-x  4 daemon   daemon     4096 Feb  7 13:18 rating
-rw-rw-r--  1 daemon   daemon     1894 Feb  7 13:18 README.md
drwxrwxr-x 23 daemon   daemon     4096 Feb  7 13:18 report
drwxrwxr-x  6 daemon   daemon     4096 Feb  7 13:18 reportbuilder
drwxrwxr-x 25 daemon   daemon     4096 Feb  7 13:18 repository
-rw-rw-r--  1 daemon   daemon     3035 Feb  7 13:18 r.php
drwxrwxr-x  4 daemon   daemon     4096 Feb  7 13:18 rss
drwxrwxr-x  8 daemon   daemon     4096 Feb  7 13:18 search
-rw-rw-r--  1 daemon   daemon      670 Feb  7 13:18 security.txt
-rw-rw-r--  1 daemon   daemon       67 Feb  7 13:18 .shifter.json
drwxrwxr-x  7 daemon   daemon     4096 Feb  7 13:18 sms
-rw-rw-r--  1 daemon   daemon     4940 Feb  7 13:18 .stylelintrc
drwxrwxr-x  5 daemon   daemon     4096 Feb  7 13:18 tag
drwxrwxr-x  6 daemon   daemon     4096 Feb 10 03:38 theme
-rw-rw-r--  1 daemon   daemon     1667 Feb  7 13:18 tokenpluginfile.php
-rw-rw-r--  1 daemon   daemon     3367 Feb  7 13:18 TRADEMARK.txt
drwxrwxr-x  2 daemon   daemon     4096 Feb  7 13:18 .upgradenotes
-rw-rw-r--  1 daemon   daemon    71995 Feb  7 13:18 UPGRADING.md
drwxrwxr-x  9 daemon   daemon     4096 Feb  7 13:18 user
drwxrwxr-x  2 daemon   daemon     4096 Feb  7 13:18 userpix
-rw-rw-r--  1 daemon   daemon     1639 Feb  7 13:18 version.php
drwxrwxr-x  7 daemon   daemon     4096 Feb  7 13:18 webservice

Moodle data directory permissions

Are the following permissions correct or incorrect for my Moodle data directory?:

 ls -la moodledata
total 6068
drwxrwxrwx  13 daemon   root        4096 Mar 19 22:06 .
drwxr-xr-x   6 barkingb barkingb    4096 Mar 20 21:54 ..
drwxrwxrwx   2 daemon   root        4096 Jan 25  2023 antivirus_quarantine
drwxrwxrwx   3 daemon   root        4096 Mar 20 22:28 cache
drwxrwxrwx 258 daemon   root        4096 Jan 25  2023 filedir
-rwxrwxrwx   1 daemon   root         128 Jan 16  2023 .htaccess
drwxrwxrwx   2 daemon   root        4096 Jan 24  2023 lang
drwxrwxrwx   2 daemon   root        4096 Mar 20 22:28 localcache
drwxrwxrwx   6 daemon   root        4096 Jan 24  2023 models
-rw-r--r--   1 daemon   daemon   6143850 Mar 20 21:49 moodle-cron.log
drwxrwxrwx   2 daemon   root        4096 Mar 20 22:20 muc
drwxrwxr-x   3 daemon   daemon      4096 Oct  9 13:49 secret
drwxrwxrwx   2 daemon   root       12288 Mar 20 21:25 sessions
drwxrwxrwx   4 daemon   root        4096 Mar 20 16:10 temp
drwxrwxr-x   2 daemon   daemon      4096 Mar 19 22:06 trashdir

I moved my backup back into the stated directory and it STILL gives the same print!

What has happened? Where did I go wrong?

Thanks.

Average of ratings: -
In reply to Barking Bandicoot

Re: Caprover upgrade fail

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
For Bitnami support, you'll need to speak to Bitnami. Or a Bitnami forum.

We can only really provide support for Moodle and we have no idea how Bitnami packaged it up. This is why we generally do not recommend these type of installers.
In reply to Howard Miller

Re: Caprover upgrade fail

by Barking Bandicoot -
Or a Bitnami forum.
Thanks, I have posted the issue there.
 
do not recommend these type of installers.
Well, I saw no warning regarding this. If I had known before hand I would have chosen differently. I now have too many services running with Caprover/docker to change unfortunately.
 
I will add to this post just in case a user can assist.
 
I ran the php upgrade.php upgrade script
This printed:
Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

I tired different permissions on the data folder:
sudo chown -R daemon:daemon /srv/moodle/moodledata
chown -R www-data:www-data /srv/moodle/moodledata
 
I also tired:
chmod -R 755 /srv/moodle/moodledata
chmod -R 755 /srv/moodle/moodledata
 
None of this worked.
 
In the config.php file
$CFG->dataroot  = '/bitnami/moodledata';
is linked to /srv/moodle/moodledata
in the Caprover/Docker settings.
I changed the path to point directly to /srv/moodle/moodledata
This printed:
php upgrade.php
!!! <p>Error: database driver problem detected</p>
<p>The site administrator should verify server configuration</p><p>PHP has not been properly configured with the MySQLi extension for it to c
ommunicate with MySQL. Please check your php.ini file or recompile PHP.</p> !!!
In reply to Barking Bandicoot

Re: Caprover upgrade fail

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

From the installation instructions: "IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.".  I know, nobody reads the instructions tongueout
 
I think you probably fixed the dataroot problem by changing the setting. You now have a second, unrelated problem. 

It means what it says. The PHP in your docker instance is missing the MySQLi extension. Again, as this is Bitnami, I have no idea how to fix that. It won't be anything to do with php.ini, though (Windows thing)
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Caprover upgrade fail

by Barking Bandicoot -
Bitnami's first and good practice instruction is to
sudo mv /bitnami/moodle /bitnami/moodle.backup
check ✅
or did I?
Looking through the moodle files in terminal I notice in my moodle.backup directory there was another directory within it labeled moodle. huh? Odd! I do not remember it being part of the structure. Indeed the newer moodle directory did not contain it. Looking into it I see the whole moodle directory repeated. Oh!!
What I must have done is:
sudo mv /bitnami/moodle /bitnami/moodle.backup/
I backed up my moodle directory within an already existing moodle.backup -rather than over-writing it!
When I copied over files I did so from an older backup thinking it was the existing backup!
I now went into the real backup and copied over the files - and have the site back online!!
What is curious though it that I am now on version 4.5.2. Curious because I swear I was on version 4.5.1 and downloaded version 4.5.3 to upgrade to! 🤷🏻‍♂
In reply to Barking Bandicoot

Re: Caprover upgrade fail

by Ken Task -
Picture of Particularly helpful Moodlers

Am not a Bitnami user.   For what it's worth:

"Bitnami's first and good practice instruction is to ..."

If you go Bitnami, go Bitnami 100% ... use Bitnami Docs

https://docs.bitnami.com/

and Bitnami Forums.

Don't mix Moodle Forums with Bitnami Forums/Support ... that's a 'mistak' (nope, spelled it correctly).

Thank goodness Bitnami is just the stack and not the entire OS/Distro for this "What I must have done is ..." can be verified with a shell command:

history [enter]

"What is curious though it that I am now on version 4.5.2. Curious because I swear I was on version 4.5.1 and downloaded version 4.5.3 to upgrade to!"

Moodle has no auto upgrade nor down grade.   So BTU&KB.  Bitnami is 100% command line, so once again:

history [enter]

and

https://docs.bitnami.com/aws/apps/moodle/administration/upgrade/

May not be in Bitnami docs, but ... to find out exact version of core you to have:

cd /path/to/moodlecode/

fgrep '$release' version.php

There are other moodle scripts in code/admin/cli/ that should be used to check before upgrading.

cron.php, checks.php, check_database_schema.php, mysql_collation.php, scheduled_task.php, and uninstall_plugins.php

And to actually perform an upgrade .... upgrade.php

Any of those mentioned in Bitnami Docs?

https://docs.moodle.org/405/en/Administration_via_command_line

And, last but not least, by far the best way to install, update/maintain, and upgrade a moodle code base is using git versioning.

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

'SoS', Ken

In reply to Howard Miller

Re: Caprover upgrade fail

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You kind of ignored what I said.

Moodle is (sort of) working but the PHP install in your Docker instance is missing a vital extension. This is NOT a Moodle issue. What you do with the Moodle code won't make any difference.
In reply to Howard Miller

Re: Caprover upgrade fail

by Barking Bandicoot -
Thank you Ken and Howard
Yes, yes, "it is a Bitnami issue" - acknowledged!!
I opened a bitnami github bug.

As I have already started this thread I thought it best to supply the resolution rather than leaving it hanging. That is, if this thread is irrelevantly clutering the Moodle content then there are two choices that are best; add resolution or delete.
Please delete this thread to unclutter the forums. I will see if I have the power to do so, but probably cannot.

"Moodle is (sort of) working but the PHP install in your Docker instance is missing a vital extension. This is NOT a Moodle issue. What you do with the Moodle code won't make any difference."
- I acknowledge your contribution and looked into this. It does not seem to have been an issue. The old extensions (due to Bitnami??) held up the upgrade. No php command would work. They all resulted in: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

"Moodle has no auto upgrade nor down grade"
- The upgrade (manual unpack) was obtained from the official Moodle packages - https://download.moodle.org/releases/latest/
I say curious at it was Moodle 4.5.3+ that I downloaded from https://download.moodle.org/releases/latest/

Again my intention of continuing here was to tie up a loose thread in good will - not to bring in more unrelated crud to the forum.
Please delete this thread if you have to power to do so.
Thanks Ken and Howard.
Average of ratings: Useful (1)
In reply to Barking Bandicoot

Re: Caprover upgrade fail

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Ok - I missed that. I might have been clearer to say "I found the problem" or similar. It really is appreciated, as many people just vanish without tell us what the resolution was.

We certainly don't remove forum posts. There's no such thing as clutter. It very well might help somebody else.