azuremoodle

Bitnami How-To Guides for Microsoft Azure

Migrate Data From One Moodle Instance to Another

NOTE: We are in the process of modifying the file structure and configuration for many Bitnami stacks. On account of these changes, the file paths stated in this guide may change depending on whether your Bitnami stack uses native Linux system packages (Approach A), or if it is a self-contained installation (Approach B). To identify your Bitnami installation type and what approach to follow, run the command below:

 $ test ! -f "/opt/bitnami/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."

The output of the command indicates which approach (A or B) is used by the installation, and will allow you to identify the paths, configuration and commands to use in this guide. Refer to the FAQ for more information on these changes.

Introduction

There are two different ways to upgrade and maintain your Moodle installation:

  • Performing a manual upgrade following these instructions.
  • Migrating your installation to a new server instance with an updated version of the application and/or underlying components before performing the manual upgrade of Moodle.

This guide describes the second option. We strongly recommend that option because it is the only way to make sure that you have also updated the PHP version. All Bitnami stacks include their own bundled PHP version. As a consequence, even if you install PHP using system packages, the stack will continue using the bundled PHP. The best way to make sure that you are upgrading the whole stack, including new versions of PHP is migrating your current Moodle installation from one instance to a new one.

Follow the instructions below to successfully upgrade all Moodle components. After this, you will be able to upgrade Moodle. That way you will have the whole stack upgraded.

We recommend that you do this from time to time to make sure that you not only have the latest version of Moodle, but also have the latest (and most secure) versions of Apache, MySQL and other software that Moodle runs on. We regularly refresh the images available in the Bitnami library to make sure that you always have access to the most up-to-date software.

Step 1: Backup existing data

Begin by creating a backup of your existing Moodle installation. To do so, perform the following steps:

  • Log in to the server console.
  • Export the database.
  • Create a copy of these directories, depending on the installation type:

    • Approach A (Bitnami installations using system packages):

      • /bitnami/moodle
      • /bitnami/moodledata
    • Approach B (Self-contained Bitnami installations):

      • /opt/bitnami/apps/moodle/htdocs/
      • /opt/bitnami/apps/moodle/moodledata
  • Stop all services:

    $ sudo /opt/bitnami/ctlscript.sh stop
    

Step 2: Prepare a new Moodle instance

To have a functional copy of the old Moodle installation ready to use in the upgrade process, you need to create a new installation in which you store the backup data.

  • Create a new Moodle instance and note the database password.
  • Log in to the server console.
  • Stop Apache:

    $ sudo /opt/bitnami/ctlscript.sh stop apache
    

Step 3: Copy the files from the old instance to the new one

To copy your files from the old instance to the new one, complete the following steps, depending on the installation type in the new instance:

Approach A: Bitnami installations using system packages

  • Delete the Moodle and Moodle data folder of this new instance:

    $ rm -rf /bitnami/moodle
    $ rm -rf /bitnami/moodledata
    
  • Copy the Moodle (/bitnami/moodle) and Moodle data (/bitnami/moodledata) folders from the old installation into the new instance.

  • After completing the previous step, the database password in the /bitnami/moodle/config.php file will have reverted to the password for the old instance. Update and replace it with the database password for the new Moodle instance.

  • Modify file permissions:

    $ cd /bitnami
    $ sudo chown -R daemon:daemon ./moodle ./moodledata
    $ sudo chmod -R g+rwX  ./moodle ./moodledata
    

Approach B: Self-contained Bitnami installations

  • Delete the Moodle and Moodle data folder of this new instance:

    $ rm -rf /opt/bitnami/apps/moodle/htdocs/
    $ rm -rf /opt/bitnami/apps/moodle/moodledata
    
  • Import the backup database of the old installation.

  • Copy the Moodle (/opt/bitnami/apps/moodle/htdocs/) and Moodle data (/opt/bitnami/apps/moodle/moodledata*) folder from the old installation into the new instance.

  • After completing the previous step, the database password in the /opt/bitnami/apps/moodle/htdocs//config.php file will have reverted to the password for the old instance. Update and replace it with the database password for the new Moodle instance.

  • Modify file permissions:

    $ cd /opt/bitnami/apps/moodle
    $ sudo chown -R bitnami:daemon ./htdocs/ ./moodledata
    $ sudo chmod -R g+w  ./htdocs/ ./moodledata
    

Step 4: Complete migration and restart services

You should have all the Moodle components upgraded. Now, you need to upgrade Moodle as well to the latest version. Follow these instructions to get the latest version of Moodle.

Last modification July 8, 2020