
Updating Moodle
Moodle is updated constantly. It is a common practice in open-source development environments. A new version is created every night and, as mentioned above, a fully tested version is released on a weekly basis. There is usually no need to install updates every week. However, there are a number of scenarios when you should upgrade your Moodle system:
- Security patches have been released
- New features have been added
- Bugs have been fixed that affect your setup
- A new version is released
There are principally two ways Moodle systems can be updated. You either run updates manually or stay up-to-date using the CVS command. Both procedures are described in this section.
Either way, before you start, make sure you put Moodle in Maintenance mode to ensure that no other user is logged in during the update. Go to Server | Maintenance mode, enter a maintenance message, and Enable the Maintenance mode:

Manual Update
The process for updating a Moodle system is as follows:
- Create a backup.
- Create new Moodle system.
- Install update.
If you are updating from a previous version of Moodle, the process is the same. However, double-check the Upgrading document at http://docs.moodle.org/en/Upgrading for any version-specific issues.
For example, if your current Moodle system is on version 1.6 and you wish to update to version 1.9, you first have to update to version 1.7, then 1.8, and finally the latest version of 1.9. However, you can update from 1.9 straight to 1.9.2.
Before you install a new update, it is highly recommended that you run a backup of your Moodle system. While most updates will run smoothly, the backup will be required if you have to revert back to the pre-update version. There are three parts that have to be backed up:
- Database
There are two ways you can create a so-called database dump from a MySQL database, either via command line or via Moodle's optional database interface.
The simplest syntax for the command line tool is:
mysqldump -u <user> -p <database> > backup.sql
If you have to restore the database, you have to use the mysql command line tool as follows:
mysql -u <user> -p <database> < backup.sql
The interface for the database tool is accessed via Server | Database. This is an optional module, and has to be installed separately (it is the MySQL Admin add-on—see Chapter 13 for more details).
Click on the Export link on the front page, select the database to export, and press Go. The output of the command will be displayed on screen.
- Data directory
This is the moodledata directory. Create a copy of this elsewhere on the server (using cp
-R
) or create an archive using the tar command(tar cvf moodledata)
. - Moodle
This is the Moodle software. Create a copy of the directory elsewhere on the server. While only some parts of this backup are required (
config.php
, added themes, modified language packs, and so on), it is a good practice to create a backup of the entire software. Finally, rename your Moodle system from moodle to say, moodle.old. (mv moodle moodle.old
).
Once you have created a backup it is time to download the new version of Moodle. This is done in the same way as described during the installation process.
First, create a new moodle directory (dirroot) and copy the new version in that location (using the same unzip or tar command as during the installation). Also make sure the permissions as well as user and group are correct.
Now, copy the following files and directories from your moodle.old
directory to your new dirroot
. Existing files have to be overwritten:
config.php
.htaccess
(only if present)- Any theme folders that have been created
- Any modified language packs
That's it. Next time you start Moodle, the update script will kick in. We'll go through it next.
Once you go to the location of your Moodle site and log in as adminstrator, the system will recognize that a new version is available and kick off the installer automatically.
The first screen displays the old and the new version of Moodle (here 1.9 and 1.9.1, respectively), and asks you to confirm that you wish to go ahead with the upgrade:

Next, a screen is displayed that provides a link to the release notes and performs the same server check as the one described during the installation:

Moodle plug-ins—core or third-party—sometimes cause problems while upgrading Moodle. The installer lists all components and states whether they are Standard, Non-Standard, or Incompatible. If the latter is the case, either replace the add-on with a compatible version, or remove it from the system via the provided Delete option. See Chapter 13 for more details.
At the bottom of the screen you can select the familiar unattended operation mode:

Once this screen is confirmed, the actual installation starts. It creates new database fields and modifies any data fields as and when necessary. Any new system settings that have been added to Moodle are shown and can be changed straightaway. For example, in the following screenshot a new Blogs parameter has been added to the Backups section:

Once the upgrade process is completed, make sure you check the Notifications page as done under Windows environment installation. Also, don't forget to turn off the Maintenance mode.
Update via CVS
An alternative approach exists to keep the current version up-to-date. It uses CVS, which is an open-source concurrent versioning system. All checked-in Moodle code is made available via this method, which allows you to update only the modules that have actually changed.
CVS has to be installed on your Moodle server. The first time you use CVS, you have to download the full version of Moodle:
cvs -z3 -d:pserver:anonymous@<mirror>:/cvsroot/moodle co d <directory> -r <version> Moodle
Select the nearest<mirror>
from the following list.<directory>
is the location where your Moodle system is installed. Specify the<version>
you wish to install, for example MOODLE_19_WEEKLY or MOODLE_19_STABLE.
In addition to the main Moodle CVS repository, there are currently five CVS mirrors as shown in the list:

Once this has been successful, go to your Moodle site and you will be guided through the same update process as just explained. If this fails, check that the user and group permissions are set correctly and adjust them accordingly (chown R <user>:<group> moodle)
.
For further updates, you should use the following command that remembers your previous settings such as the chosen mirror site:
cvs update -dP
For further options of how to use CVS from the command line and in operating systems other than Unix, check out http://docs.moodle.org/en/ CVS_for_Administrators.
Because CVS is a shell command tool, it is possible to fully automate the updating process. However, if you have changed any core code, potential conflicts might arise that have to be resolved (CVS will prompt you to do so).
You might also come across some conflicting advice regarding whether to use CVS for production sites or not. The advantage is that your system is always up-to-date and that the updates are carried out automatically. The disadvantage is that the update process might require intervention to resolve any conflicts, or it might fail, especially when a lot of third-party add-ons have been employed.