Moodle V4.3 update script fails

I bought the Virtualmin pro just for getting easy setup with Moodle through the Moodle script. But already two times I have to spend hours to get the update going. For installing Moodle, it worked great. But updating fails every time. Can this be fixed?

Rob Oudendijk

P.S love the VirualMin team. Very nice work they delivered.

Can you be more specific? What update failed? What errors did you get?

1 Like

I had V4.2.3 installed in the root of my web server and the Moodle script mentioed it had an update, and so I pressed update. Moodle came back with the update did not succeed, and I had to restore V4.2.3 seems the update script does not automatically update the DB.

I hope this helps troubleshooting the update issues.

Rob Oudendijk


If I understand correctly, you updated Moodle from Moodle directly, not via Virtualmin?


No, that is incorrect. I did install Moodle with the script. Installed in plubic_html because the Moodle site would be needed in the root of the domain. And updating Moodle through the script did not work. I do recall from 4.1 t V4.2 I had to do the same. One time with an in between version, it worked nicely. Not sure why this is happening.

Rob Oudendijk

I have installed Moodle on virtualmin for a year. I recommend installing it as the Moodle documentation guide, it is as simple as downloading the zip and unzipping it in public_html. The update is carried out in the same way, the same procedure also applies for server migration


Okay, let me see if I’m reading this correctly. You installed Moodle via Virtualmin, and did the update via Virtualmin?

The reason I ask is so I can provide appropriate instructions.


Thanks for the response. So instead of using the script to update, follow the Moodle documentation?
I had done that for going from 4.1 to 4.2 when the script update did not work. And that procedure worked well. I remember.


Updates should work in Virtualmin, if Virtualmin offers to update it. But, if something about the process has changed since it was developed that can obviously break. We’ll have to do some testing.


@robouden1 Rob, what distro and version are you on?

Also, did you previously install Moodle using Virtualmin and recently came 4.3 upgrade which you updated using VIrtualmin, and then things did not work right? Is that how it was?

I think I also see an issue upon upgrade. It seems we need to unlink previous installation files as explained here:

Mixed Moodle versions detected, upgrade cannot continue

The Moodle update process has been paused because PHP scripts from at least two major versions of Moodle have been detected in the Moodle directory.

This can cause significant problems later, so in order to continue you must ensure that the Moodle directory contains only files for a single version of Moodle.

The recommended way to clean your Moodle directory is as follows:

  • rename the current Moodle directory to “moodle_old”
  • create a new Moodle directory containing only files from either a standard Moodle package download, or from the Moodle Git repository
  • move the original config.php file and any non-standard plugins from the “moodle_old” directory to the new Moodle directory

When you have a clean Moodle directory, refresh this page to resume the Moodle update process.

This warning is often caused by unzipping a standard Moodle package over a previous version of Moodle. While this is OK for minor upgrades, it is strongly discouraged for major Moodle upgrades.

This warning can also be caused by an incomplete checkout or update operation from the Git repository, in which case you may just have to wait for the operation to complete, or perhaps run the appropriate clean-up command and retry the operation.

@Jamie, I will take a look.

1 Like


Good, I am not the only one with the update issue.

The way I could update before:

  • Put site in maintenance mode

  • root login in
  • cd Downloads
  • wget latest for Moodle site
  • unzip moodle
  • cp -r moodle /home/transom/domains/
  • cd /home/transom/domains/
  • cp -pr public_html/config.php moodle
  • cp -pr public_html/theme/adaptable moodle/theme/adaptable
  • cp -pr public_html/mod moodle/
  • cp -pr public_html/blocks moodle/
  • cp -pr public_html/question/type moodle/
  • cp -pr public_html/admin/report moodle/
  • chown -R transom:transom moodle
  • cp -pr public_html public_html_old
  • mv moodle public_html

  • Login into lms moodle
  • Upgrade the database and plugins

  • Disable the maintenance mode.

I wonder if there’s a way we can do a an upgrade by removing the conflicting files from the old version, rather than renaming the entire directory?

1 Like

Yes, the I have spent most time of today figuring this out. Latest patch to install script will do upgrades properly. It will also make a backup of current installation and attempt to migrate existing custom modules and themes upon upgrade.

Post install messages are improved as well, e.g.:

@Jamie, let me know if we can already easily access currently installed version of the script, and I will fix the code further to diff again currently installed version for higher precision.

If it isn’t straight forward, then script_*_install, i.e. install_func should also receive currently installed version of the script as a parameter.

Then, as I just mentioned we could diff with more accuracy against existing version. At the moment the diff is made against new version, which isn’t ideal and potentially can break in major version upgrades.

1 Like

The 5th param is a hash ref that contains details of the version being upgraded from.

1 Like

Jamie and LLia,

Thank you for working fast with a solution.
How to get access to the script, so I can use it?

Rob Oudendijk

Yes, missed that. Alright fixed now! Moodle upgrade process should be much more precise now!

It will arrive to your Virtualmin Pro instance within next 24 hours.

1 Like


Looking forward, testing it.

Hugs and peace,
Rob Oudendijk

Thank you, Rob! :peace_symbol:

1 Like


Sorry, one more question about the script. How to know that it is the latest version of the script?
All the information I have from the script seems not visual. Would be nice to know what version of the script is installed from the GUI.

Rob Oudendijk