System-level backups

System-level backups cannot be configured or executed from within Moodle. Instead, they will have to be set up on the system (shell) level. If your system is hosted externally, there is a possibility that you will not have access to the system level, which will prevent you from performing this type of backup. Unless the host already runs system-level backups on your behalf, it is time to change to another provider!

There are two types of system backups that are not mutually exclusive:

  • Moodle backups: These create an archive of Moodle itself, the course content, and user data.
  • Snapshots: These create an image of the system, which is used for disaster recovery purposes, that is, if the system has to be rolled back in its totality.

Moodle backups

Moodle distinguishes between the application software itself and the data that is stored in it. The advantage of this separation becomes apparent when creating backups: a software backup is only required when an update has been installed or customization is taking place, whereas, data has to be backed up more frequently.

The Moodle software

Backing up the Moodle software itself is straightforward. All you have to do is to create a copy of the directory and all its subdirectories where the Moodle software is installed (usually called moodle). Most administrators would create a single archive of the directory for easier handling (in Unix, use the tar command with the –cvf parameter called tar -cvf <backupfile>). This step is usually only required before a system upgrade or when you need to archive your entire system.

The Moodle data

Moodle stores its data in two separate locations:

  • Moodle database: Most content is stored in the Moodle database. You can either use the export feature of phpMyAdmin (if installed) or use the following mysqldump shell command for MySQL to create a single backup file:
    mysqldump -u <username> -p [-h <databasehost>] -C -Q -e -a <database> > <backup-file>.sql
    
    • The <username> option has to be replaced with the -p database username and will ask you for a password, and–h <databasehost> is only required if the database is located on a separate server. The <database> option is the name of the database, and <backup-file> is the name of the archive to be created. It is common practice to use the .sql extension.
    • To recover the database dump, use the following mysql shell command:
      mysql -p <database> < <backup-file>.sql
      

    Note

    For more information on mysql and mysqldump, check out the reference sites at http://www.mysql.com/. For other database types, refer to the respective administration guides.

  • Moodle data directory ($CFG->dataroot): This is where all the course content resides, for instance, assignments, user profiles pictures, forum posts, and so on. Like the Moodle system, all that has to be done is create a copy of the directory and all its subdirectories. Most administrators would create a single tarball of the directory for simpler handling (in Unix, use the TAR command with the –cvf parameters).

Tip

It is important to stop Apache while performing the backup to guarantee that the content is not getting out of sync.

The advantage of this approach is that it is less resource-intensive, can be scripted, and recovery of the full Moodle system is far more straightforward. However, it is impossible to retrieve individual activities without setting up a temporary server, as is possible with course backups.

Snapshot creation

The creation of snapshots is only briefly mentioned for completeness as it is not a Moodle administrator role but a system administrator task. However, you should make sure that such a mechanism is set up in case of any hardware failures or as a way to run a reliable backup of your system.

A snapshot is basically an image of the entire partition on the hard disk that contains the Moodle software itself as well all the data (database and data directory). The advantage of the snapshot is that the entire system can be rolled back to the point when the image was created. However, any data that has been added or modified since this point in time will be overridden. Snapshots cannot be used to recover a single course or parts thereof, but can only be used for a full replacement of the system.

Tip

No matter what combination of backups you choose, frequently verify that the backup procedure is actually working. There is nothing worse than a false sense of security, that is, assuming that all your data is backed up when it isn't!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.120.136