Migrate Data From One Moodle Instance to Another
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:
Stop all services:
$ sudo /opt/bitnami/ctlscript.sh stop
Rename the installation folder:
$ sudo mv /opt/bitnami /opt/bitnami.backup
Step 2: Copy and restore data on the new 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. To copy your files from the old instance to the new one, complete the following steps:
- Create a new Moodle instance and note the database password.
- Log in to the server console.
$ sudo /opt/bitnami/ctlscript.sh stop apache
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
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
$ sudo /opt/bitnami/ctlscript.sh start apache
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.