ibmmoodle

Migrate Data From One Bitnami LMS Powered by Moodle(TM) LMS 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:

  • Perform a manual upgrade following these instructions.
  • Migrate 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 (preferably using the latest available version to ensure that you have the latest security and bug fixes) 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 approach followed by the new instance:

Approach A: Bitnami installations using system packages

If the old Moodle deployment followed Approach B and the new deployment follows Approach A, copy the new deployment’s configuration file to a safe location before proceeding:

$ sudo cp /bitnami/moodle/config.php ~/

Continue the process as shown below:

  • 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.

  • The next step depends on the approach followed by the old Moodle deployment.

    • If the old Moodle deployment followed Approach B and the new deployment follows Approach A, copy back the new deployment’s configuration file. After this step, the database password in the /bitnami/moodle/config.php file will be the password for the new instance.

          $ sudo cp ~/config.php /bitnami/moodle/
      
    • If both the old and new Moodle deployments follow Approach A, the database password in the /bitnami/moodle/config.php file will have reverted to the password for the old instance. Update this file 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 now have the latest version of Moodle with all your data migrated.

Last modification June 16, 2021