How to Upgrade Moodle

This article guides you on how to upgrade Moodle on the Cloud Clusters Platform.

1. Take a snapshot

Prior to the migration, make sure that all of your data is backed up, especially the files that you'll be migrating. If you encounter any problems during migration, such as corrupt, incomplete, or missing files, you'll have the ability to correct the error by restoring the data in it's original state. If you need help, please refer to this guide on how to take a system bakcup.

2 Put your site into maintenance mode

  • Log in to the Client Panel and locate your target deployment on the Home page or the My Applications page.

  • Click the "Manage" button on the Home page or the My Applications page. Then Click the "Shell / SSH" tab in the menu bar.

  • On the Shell / SSH page, click the "Connect" button to initiate a shell session. You can issue commands in it.

    Note: For security reasons, the function is only open to the account holders who have passed our verification process. If you would like to enable it, please update your billing information.

  • Execute the command line to put your site into maintenance mode.

    cd /cloudclusters/moodle/html
    gosu www-data php admin/cli/maintenance.php --enable
    

3. Back up the original html file

Rename the html file from html to html.back by using the command

mv /cloudclusters/moodle/html   /cloudclusters/moodle/html.bak

4 Download the Moodle project from git

Use the following commands to create a temporary directory under /cloudclusters and download the Moodle project to the temporary directory.

mkdir /cloudclusters/tmp && cd /cloudclusters/tmp
git clone git://git.moodle.org/moodle.git

If git is not installed, please use the command to install git first.

apt update && apt install -y git
git clone git://git.moodle.org/moodle.git

After the Moodle project download, please rename moodle to html and move the project to /cloudclusters/moodle. Then update the permission.

mv moodle  /cloudclusters/moodle/html
chown www-data:www-data /cloudclusters/moodle/html -R

5 Upgrade Moodle

  • Check the current Moodle version

    cd /cloudclusters/moodle/html && cat version.php
    

  • Check the available versions

    git branch -av
    

  • Upgrade to the latest version Depending on which version you are upgrading from, please see the section 'Check the requirements' and 'Possible issues that may affect you' in the documentation: For example, You can only upgrade to Moodle 4.2 from Moodle 3.9 or later. If upgrading from earlier versions, you must upgrade to 3.9 as a first step.

    In this case, we have a MOODLE_400_STABLE deployed in our server, we need to let our local branch to track the remote branch. Please use the following command: -

    git branch --track MOODLE_400_STABLE origin/MOODLE_400_STABLE
    git checkout MOODLE_400_STABLE
    git status
    
  • Copy the config.php file from html.bak file to the html directory

     cp -a ../html.bak/config.php .
     gosu www-data php admin/cli/maintenance.php --enable
     git config --global --add safe.directory /cloudclusters/moodle/html
     git pull
    
  • Upgrade

    Check current version.

     cat version.php
    

    Upgrade Moodle version

    gosu www-data php admin/cli/upgrade.php
    

    Check if the upgrade succeeds.

     cat version.php
    

6 Disable the maintenance mode

gosu www-data php admin/cli/maintenance.php --disable

Go to Site administration > Notifications, then scroll down to the bottom of the page.

You can also log in to your Moodle admin panel as administrator to check if the upgrade succeeds.

Copyright © 2021 Cloud Clusters Inc. all right reserved,powered by GitbookRevised on 04/26/2023

results matching ""

    No results matching ""