Site Backup for Low-tech Users
Note: You are currently viewing documentation for Moodle 3.1. Up-to-date documentation for the latest stable version of Moodle is probably available here: Site Backup for Low-tech Users.
This page is written for Moodle site administrators who are interested in learning about site backup and restore process, but who are not familiar with code, command lines or website administration. For others please see Site backup.
A complete Moodle site backup involves 3 things: the Moodle code, the moodledata folder and the MySQL tables. A course backup and download off site is always a best practice but it only involves parts of the moodledata folder and SQL table.
- TIP: Please remember there are many different configurations for webservers and Moodle sites. Most of the instructions below should start with the words "Generally speaking".
- 1 Before disaster strikes
- 2 Course Backups - better than nothing
- 3 Backup up key folders
- 4 Backup the MySQL database
- 5 Tips and tricks
- 6 See also
Before disaster strikes
"Do not gamble what you can not afford to lose": think carefully about how often you will backup things and where.
When a major Website disaster happens, you may need to restore the three parts:
- moodledata folder - sometimes called the: data files, Moodle files, data directory, uploaddata, dataroot, or simply moodledata (in lowercase). It is not called the "database".
- MySQL or PostgreSQL database - We will refer to the MySQL database. There are other SQL database flavors which will work with Moodle.
- Moodle code - location of Moodle code.
Thus it is a good idea to first know how to backup these parts so you can restore them to a new or existing webserver.
Course Backups - better than nothing
As the site administrator, you probably have set an automatic course backup in your site settings. Sometimes site administrators forget that these backups should be copied to a safe place other than their webserver. Teachers maybe encouraged to download their course(s) backups to their computer on a weekly basis.
The course backups and restores only deal with parts of the moodledata folder and MySQL tables. For example, they may include reference to a default theme or a contributed code module, but not the actual code or information that will make them work.
Backup up key folders
You will need a program and rights to go into your website files to make a backup. You can copy the folder to another off site location, or zip the folders and copy that zip file to another location.
An FTP (file transfer protocol) program might be useful. There are free programs such as CyberDuck and FileZilla. A FTP program copies a file from "there" (the server) to “here” (your desktop). Usually this is as simple as a drag and drop and then waiting for the files to transfer.
Some webhosts will have an interface that will allow you to create a zip or tar file and download it from the server to your desktop, similar to a FTP program.
Back up your moodledata folder
Use your program to copy (that is, drag and drop) the directory called “moodledata” or the zip or tar file you created that contains this folder. This folder was named and created in the install process. It usually located in a public directory, not in the same directory as the moodle code folder.
Backup the moodle code folder
Use your program to copy (that is, drag and drop) the directory that contains the moodle code. This directory is usually called "moodle" and maybe in the public root (htdocs). You may have created a tar or zip file of this directory and it's contents.
- Tip: Some sites only use the standard install package. And some of the site administrators of these sites like to use a clean install of their Moodle code, instead of using a backup as described above. A potential problem with this practice may involve sites that have added modules or tweaked the standard Moodle, because these things will not be in a standard install.
Backup the MySQL database
Backing up the MySQL database is a different process and uses a different type of program. Here is a video of the process.
MySQL can be thought of as a series of databases. Each database is made up of tables that share a common prefix in their name. Each table has records. The Moodle intaller creates the Moodle tables prefix. A typical prefix is "mdl_". The goal is to backup these tables.
phpMyAdmin can be installed as part of the Moodle interface. When installed it can be found in the site administration block>Server>database. Many webhosts will use a program called cPanel, or have a link to program that can manage the MySQL database such as phpMyAdmin. We will use phpMyAdmin.
Open phpMyAdmin. In the left pane, you will see your database(s) listed. Normally, the name of a Moodle database will be something like mdl_ or have the description Moodle. Click on the database you want to back up.
The page will refresh. In the left column you should see all (around 200) the tables with the prefix of mdl_ (or what ever they were named when the Moodle site was installed). Along along the top you will now see a row of buttons. Click on the button Export.
You will see boxes with options in them (see below).
- Check “Select all. ” In the Structure box
- Click “Add DROP TABLE, etc.”
- When in doubt, leave a setting at it's default
- Go down to the bottom and find “Save as file”
it is a good idea to today’s date to the default name.
- Select the compression method (here we selected gzipped)
- Press Go in the lower right corner
A popup window will ask you whether you want to save the exported file. Click OK (Save). Wait for the process to finish.
phpMyAdmin will zip a copy of your database and send it to your home computer’s desktop.
Tips and tricks
Useful and free books
Every Moodler should download the free book Using Moodle 2nd edition in .pdf. https://docs.moodle.org/en/Using_Moodle_book It tells you all about how to create Moodle courses. Its final chapter (16) describes basic system administration, including how to automate the backing up of your courses. That automated course backup is really simple and you should do it.
The rest of Using Moodle’s final chapter explains the administration settings on Moodle’s front page. All those explanations are vital. However, Using Moodle does not tell you how to backup your whole site.
Beginning administration FAQs
cPanelis a common webhost interface, where you manage what you have on your hosted server space.
You probably used cPanel when you installed Moodle. It includes File Manager. In addition, cPanel includes phpMyAdmin that we discussed above.
Another Site Backup
It is a good practice for a site administrator to have a test site not on their production server. If you have a spare computer capable of Internet connection, you can create a backup/test Moodle site. This is a great way to develop your abilities and test the process without using your production site. See one of the Complete install packages.
- TIP: Create two different webservers as localhosts with the complete install packages. Turn on one and set it up as your production server. Turn it off and turn on the other webserver as perform the restore process on it. Hopefully you will not need to do this on your real production server, but you can practice.
What else should you back up?
There are a few webserver files that might be handy to have.
Moodle software is supported by three other types of software packages: a webserver (Apache), the PHP code processor and a database(MySQL) server. These will be installed on the webserver. A webhost will generally maintain and updates these and other packages. These programs work with Moodle code and communicate with each other.
It’s good to read the Site Backup FAQ  You will not understand everything, but that’s OK.
Experienced system administrators back up their sites according to instructions here:  But that page assumes that readers can write Unix/Linux commands and php code. We have give you a simplier alternative above.
Backing Up before an upgrade or adding a new module
Backing up prior to upgrading Moodle, needs special attention to details. Remember, when you upgrade Moodle, it will change the Moodle code, and probably the MySQL tables and perhaps things in the moodledata folder. This is also true if you are tweaking the code or adding contributed code. The old parts may not be compatible the new.
If for some reason the install does not work, you will probably want to roll things back by restoring the backups you made of MySQL, the Moodle code and moodledata.
You can see a forum discussion of this issue, reguarding Fantastico to install Moodle, here.