How to Back Up and Restore a Moodle Site
All of our Moodle themes are now fully compatible with Moodle 5.3

How to Back Up and Restore a Moodle Site

Administrator protecting and restoring Moodle database, code and uploaded files

A complete Moodle site is more than its course backup files. To recover the whole platform, you need a consistent copy of the database, the moodledata directory and the code/configuration. Losing any one of those can leave courses, files or plugin behaviour incomplete.

Site backup versus course backup

A site backup protects the installation. A course backup creates an .mbz package containing selected course content and, when permitted, user data. Course backups are useful for copying or archiving courses, but they are not a substitute for disaster recovery.

The three parts of a full Moodle backup

  1. Database: users, configuration, grades, activity records, links and metadata.
  2. moodledata: uploaded files, generated files and stored content.
  3. Code and config: Moodle version, config.php, themes, plugins and controlled custom code.

Capture the database and file data from the same maintenance window. If users keep submitting work while the two are copied at different times, the references in the database may not match the files.

Build a dependable site-backup process

  1. Define recovery-point and recovery-time targets.
  2. Use your database engine’s supported dump or snapshot method.
  3. Copy moodledata while writes are stopped or through a snapshot system that guarantees consistency.
  4. Archive the code and configuration, including a plugin/version inventory.
  5. Encrypt backups containing personal data.
  6. Store copies away from the production server and restrict access.
  7. Retain multiple generations so corruption is not copied over the only good backup.

Do not place backup archives inside a web-accessible directory. Monitor job completion and storage capacity; “scheduled” does not mean “succeeded.”

How to restore a complete site

  1. Provision a server that meets the restored Moodle version’s PHP and database requirements.
  2. Keep the site unavailable to ordinary users.
  3. Restore the Moodle code and config.php.
  4. Create an empty database and import the database backup.
  5. Restore moodledata to the configured $CFG->dataroot.
  6. Correct ownership and permissions for the web-service account.
  7. Update database credentials, $CFG->wwwroot and paths only if the destination changed.
  8. Purge caches, run cron and test the site before reopening it.

If the URL changes, follow Moodle’s migration guidance. Do not run a blind text replacement against a live database without a backup and a tested procedure; Moodle data can contain serialised or structured values.

Back up an individual course

In the course, open More > Course reuse > Backup or the equivalent course navigation item. Select whether to include enrolled users, activities, blocks, files and other data. Review the schema, perform the backup and download the resulting .mbz file if it must be stored outside Moodle.

User-data inclusion requires the appropriate capability and has privacy implications. For a reusable template, exclude real learner data unless it is genuinely required.

Restore a course

Open the destination course or the site restore area, upload or select the .mbz file, review its contents and choose whether to restore into a new course, merge into an existing course or delete existing content first. The last option is destructive; verify the destination carefully.

Map roles, dates and settings during the wizard. After restore, check files, question-bank categories, groups, completion, gradebook calculations and external-tool links.

Test recovery, not just backup creation

Run a scheduled restore exercise in an isolated environment. Measure the time, document missing dependencies and verify a representative file, login, course, grade and scheduled task. A successful archive command proves only that a file was written—not that the service can be recovered.

Frequent backup failures

  • The database dump completes with an error or zero useful data.
  • moodledata is copied without hidden files or with wrong permissions.
  • Backups remain on the same disk as production.
  • The archive contains no config.php or plugin inventory.
  • Automated course backups consume all storage.
  • No one knows the encryption key or restoration credentials.

Final advice

Keep the process versioned, monitored and rehearsed. When rebuilding the learner experience after a recovery or migration, maintained visual components from Themes Almond can help—but always restore function and data before design.

Source check: Verified against Moodle’s official Backup overview, Site backup and migration guidance.

One Reply to “How to Back Up and Restore a Moodle Site”

  1. This really helped me out today. Thanks a lot.

Leave a Reply

Your email address will not be published. Required fields are marked *