Backups

Backup The Moodle Database

Moodle Database Backup

MySQL Database Dump

  1. Backup Moodle database with the command below
mysqldump -u [username] –p[password] [database_name] > [dump_file.sql]

The parameters of the said command as follows:

  [username] - A valid MySQL username
  [password] - A valid MySQL password for the user (leave empty to be prompted for password)
  [database_name] - A valid Database name you want to take backup
  [dump_file.sql] - The name of backup dump file you want to generate

Downloading the file

  1. Download the file a backup medium for safekeeping

Backup The Moodle Data Folder

Backing Up The Moodle Data Folder

Compress the data folder

  1. Compress the Moodle data folder with the command below
tar -czvf name-of-archive.tar.gz /path/to/moodle-data-folder

Here’s what those switches actually mean:

  -c: Create an archive.
  -z: Compress the archive with gzip.
  -v: Display progress in the terminal while creating the archive, also known as “verbose” mode. 
      The v is always optional in these commands, but it’s helpful.
  -f: Allows you to specify the filename of the archive.

Downloading the file

  1. Once the folder is compressed, download to a backup medium for safekeeping

Backup Moodle Config.php

Although not necessary, you can also backup the Moodle directory and not just the config.php file.

Follow the same steps set out in Backup the Moodle Data Folder

Backing Up Moodle's Config File

  1. Copy the config.php found in the root directory of the Moode installation to a safe medium backup medium