How to Backup Moodle

Once you’ve got a cursory grasp of Moodle, if you’re a teacher or administrator, you need to learn how to backup Moodle. It’s important, for security, progress and efficiency, to frequently backup any kind of database structure, and while it has additional, tasked functionality, Moodle is at its heart a database.

This isn’t a difficult task, but it does involve a little bit of technical understanding, but take heart, it’s very easy. After you see how to do this once, it’s easy to do in the future, with little thought. So, with that said, what’s involved in how to backup Moodle?

Well, for starters, there are multiple things that can be backed up in Moodle, both wide-reaching and specific. Today, we’re going to cover the main database backup and Moodle itself being backed up as is currently configured, as well as uploaded files. But, in the future, I’ll talk about specific course backup and restore, ad course automation backup.

Looking in the config.php file, you will see some lines of slightly strange code. These are stored values for the locations of your files, among other things. The ones to double check are:

$CFG->dbname, which contains the database name.

$CFG->prefix, which shows your database table name prefix.

$CFG->dataroot, which controls where file uploads go.

And, finally, $CFG->wwwroot which shows where Moodle’s code is located.

You do not need to modify these, just make sure you or administration confirm these point where they should, by your setup.

To back up the database and these files, you can simply copy all the files and code to zip files, stored on a backup medium, and being sure to place them back where they belong, when restoring. To backup the database, consult database backup instructions for the type of database you’re using. There are a lot of ways to do this, and a lot of database systems which Moodle is able to use, so I can’t really cover that here, due to its diversity.

When you restore the database, consult the config.php file above, create the directories it calls for if they are not present, and restore the zipped code and upload files as they were previously. Upon accessing Moodle, everything should work as it did in the last backup, if this was done correctly, and the intrusion or error that required a backup restoration was remedied properly.

This sounds too easy, and the technical aspect of this I mentioned is merely wading through that PHP file to look at those values I showed, and whatever may be involved in backing up the database you are using in Moodle. Chances are, it’s MySQL, which you can check in your Moodle configuration, in which case, it’s not complicated, and a lot of documentation on backing up and restoring this type of database is prolific on the internet.

I would like to have given you a more comprehensive set of steps for the general task of how to backup Moodle, but for more specifics than this, I’ll be touching on courses and other specific items, which are backups within Moodle, and therefore different.

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.