How to Migrate Moodle to a New Server

It’s time to learn how to migrate Moodle to a new server. Just like the installation process, it’s not actually that hard. It’s pretty straightforward so don’t panic at the mention of technical jargon. (Those who aren’t computer specialists or web administrators may have to step outside their comfort zone, but I will guide you through the process).
Take a deep breath, here we go.

Migrating Moodle to a new server involves changing your domain and IP address to the new server.

  • First, you must place Moodle in maintenance mode, so that administrator accounts cannot log in, and no new additions or changes to the Moodle database(s) can be made. (Maintenance mode does not prevent admin logins, however, so you need to make sure that all users with admin access do not log in during this time.
  • Next, make a database backup through the Moodle site backup system. This will create a text file with the MySQL dump.
  • Copy the Moodle code from the /documents/ directory of your server, to the (if applicable) new folder of the same name on the new server.
  • Change the entry $CFG->wwwroot in your new Moodle directory, to match the new location. This will be located in your config.php file.
  • Next, copy the moodledata directory to its new location, and change the $CFG->dataroot entry in config.php to match the new location (that is,  if the migration affects it). If you have a new URL, due to domain changes, you need to change this in the Moodle database.
  • Finally, import the dumped MySQL database file into the new server, and use Moodle’s import wizard to bring in the new database. This can be done via commandline or via the web interface. If you’re unsure how to work with the standard database dump/restore, consult your administrator. (Database restore works the same in Moodle as it does in other systems).

If you’re unsure how to handle any part of this process, do not attempt to fix it alone, as making a mistake with this can have lasting consequences on the data that is being migrated, including total data loss.

Test it out.  Test whether your migration was successful by running through the admin login of Moodle via your new address. Try to view courses as a teacher and as a student. If everything seems to be ‘where it was’, and no missing data errors occur, then everything went fine.
It’s advisable to hang on to your backed-up files for a while, in case something went wrong (you can always delete them in the future).

So, there you have it. Just follow the Moodle migration process step by step, and your Moodle move will be a piece of cake.

 

Nicole Lewis is the Lead Author & Editor of MyLMStips. MyLMStips is dedicated to providing the most engaging topics, information, tips and tricks surrounding Moodle®. It's a place where Moodle® users can receive guidance on how to get the most out of it and increase their productivity and progress.