Moodle Migration Basics
There are usually times when you may want to undertake a Moodle migration. For example, you may wish to move your Moodle site from a shared hosting service to a paid dedicated server. But what stimulates Moodle migration? Well, factors that may trigger a migration are varied and include security concerns, lack of official support from your current Moodle and most importantly, desire to take advantage of new features and functionalities being offered by latest Moodle.
For instance, Moodle 2.6 version comes with essential features for student, teachers and administrators. Moodle 2.60 SCORM has also been enhanced and it is now providing extensive support. At times, moving your Moodle from one server to another may promote performance and speed. Hence, improving scalability of a Moodle to a new level. Although there are two main ways of performing a migration, the tips below come in handy in ensuring a successful migration. I am a web designer and I have proved that they work. Just have a look.
What to do Before Commencing Moodle Migration
Enable Maintenance Mode
First and foremost, place your existing Moodle site in maintenance mode to block any login. This is vital to ensure that no data addition to the databases occur when migration is in progress. Putting your website on maintenance mode blocks public member from accessing it. It is important no to let administers log in since they are not affected by the maintenance mode.
Putting your site on maintenance mode is also important to avoid modification to the information in your databases during the migration. It is also necessary to prevent hackers from attacking your systems. Attempts to add or modify data when performing migration normally results to loss of data or corruption of files. Ideally, put the Maintenance mode on to prevent accessibility of the website to the public during future maintenance as well.
Back Up Data in your Current Moodle
Another important Moodle migration startup tip is to backup your current database. Prior to commencing the migration, transfer all the information in your database to secondary storage devices such as tape, external hard disks, flash disks or CD. Failure to back up all vital student’s information such as contacts, enrolment and fees details can have disastrous results in learning management. As a standard procedure, it is wise for management to maintain backup systems to mitigate the risks of loss if a migration fails.
To backup the data, follow the instructions given in site backup page or upgrading Moodle page of your current Moodle manual. It will give you a text file with MYSQLdump. Database backup should be done daily even when no Moodle migration is being performed.
Copying Right Directories
It is important to copy the MOODLEDATA folder from your previous install. Once you have successfully run a migration, you will need to check the data given in the code pointing towards the right directories. It is advisable to upgrade from 1.90-2.10, then 2.20-2.50 and then move on to 2.60. Phasing reduces the risk of files being corrupted during the migration.
Tips on Performing the Actual Moodle Migration
- Change $CFG-wwwroot: Change your $CFG-wwwroot variable in the config.php file for the new server. Then, Copy the content in your data directory to your new server.
- Review Moodle data permissions: Check and confirm that permissions to perform various tasks remains the same on your new data-root folder and ensure you change the value in cases where you have placed it in a new location on your new server.
- Change Moodle URL: If your URL has changed, you’ll need to update the change in the Moodle database of your new server. New URL update in Moodle databases is required since links to Files, pictures, videos, etc. are maintained as absolute links and as such, any reference they make will be pointing to the old $CFG-wwwroot value which cannot be found. In such cases, a whenever you run a MySQLURL you have requested cannot be found or does not exist message displays.
There are 2 Ways of Changing Moodle URL:
a) Method one updates the Moodle URL using Moodle script replace.php while your website is still running but just before you back up your Moodle database data. All you have to do is direct your browser to http://yourserver.com/admin/tool/replace/index.php.
If you are on an old version, direct your browser to http://yourserver.com/admin/replace.php. Then, type the URL of your old server (http://oldserver.com/) and then your new server URL (http://newserver.com/) and it will update the links to MySQL tables automatically.
Additionally, make sure to clear all your web cached links by rebooting your webserver. You may now take another backup of the Moodle database as this will contain the updated URLS.
b) Method 2 is to back-up Moodle database first, and then utilize the search and replace feature in your text editor. You can also use a Unix tool such as sed to help you replace all the old URL with new once in MYSQL backup files. Here is a sample Sed command:
#sed -e ‘s/oldserver.com/newserver.com/g’ oldmysqldump.sql > newmysqldump.sql
Note that his method does not replace texts and URL in block since they are stored in base 64 and encoded in database. As such, links in blocks are not updated. To solve this demerit, you should use the find and replace feature of your text editor to update such links.
It is always wise to check and confirm that mysqldump file is well referenced as given in the old server. Once you have finished checking the files, simply restore the MySQL database.
A point of caution here, if you used method one, is to remember to use the updated Moodle database backup. Otherwise, you will get a broken link warning every time you run a MySQL query that needs to reference an absolute link.
Test the Migration
Lastly, test whether your Moodle migration has been successful. To do so, try to access it from your browser using the new server URL. If you have followed all the steps correctly, it should work.
Try and access a good number of links in the courses work and if you are satisfied with its functioning, take the new Moodle out of maintenance mode. It will then be accessible to the public and administrator may login as well. That’s all on Moodle migration, nothing complex.