Migrate your Moodle installation

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

There are two important steps when migrating a Moodle Stack: migrate the database and migrate the moodledata/ folder. You may want to migrate the themes/ and modules/ folders if you have them installed also. To make this process easier, divide them into four sub-steps.

Export the database

You can do this manually or with phpMyAdmin. If you use phpMyAdmin, export it as an .sql file.

Copy the Moodle data folder

In this step, you just need to copy the installdir/apps/moodle/moodledata directory to the machine where you have installed the new Moodle. When doing this step, copy the exported database file too. If you have themes or modules installed and you want to keep them, you must also copy them.

Import the database

Delete the tables in the bitnami_moodle database. To do so, the easiest way would be to use phpMyAdmin, choose the bitnami_moodle database, select all the tables and drop them.

Another option would be to do it manually. Remember to replace the PASSWORD placeholder with the password in the installdir/apps/moodle/htdocs/config.php file.

$ mysql -u root -p
mysql> drop database bitnami_moodle;
mysql> create database bitnami_moodle;
mysql> grant all privileges on bitnami_moodle.* to 'bitnami'@'localhost'
identified by 'PASSWORD';
mysql> flush privileges;
mysql> exit;

After that, import the database. You can do it manually or using phpMyAdmin.

Substitute moodledata/ (and other) directories

Finally, you just need to substitute the moodledata/ directory, as well as the themes/ and modules/ directories if needed.

Once these steps are complete, restart the Apache server and access Moodle through the browser. If you log in as an administrator, you will be asked to update your database. Click to do this and the migration of your Moodle stack will be completed.

Thanks to @aguayomanel and @pivot_1990_69 for their guides.

Last modification September 13, 2018