Vault

How Vault works

Vault backs up your entire Moodle™ site to the cloud storage and then allows you to restore it on the same or different server. Because Vault uses Moodle APIs to access database and files, the migration can be performed not only on a different Moodle version but also on a different database engine and file system.

Vault has three parts: the tool_vault plugin on your Moodle sites, the Vault API with its database, and the storage for the backups. The plugin makes a full backup of a site and uploads it. On another site, the plugin checks the backup, restores it and, if needed, upgrades the site.

Where your data goes

Your Moodle site
tool_vault plugin
  • API key validation
  • instructions to start a backup or restore
  • list of backups
  • presigned URL to upload/download a chunk
Vault API and database
accounts, API keys, backups metadata
always in the EU (Ireland)
  • getting presigned URLs
  • deleting expired backups
  • compressed data chunks
Storage
the backups
region you choose, or your S3 buckets

Backups never pass through Vault's API. For each chunk, the API creates a temporary presigned URL, and the plugin uploads or downloads the chunk directly to or from the storage. The API and its database, with your account, API keys and the list of backups, are always in the EU (Ireland).

What's in a backup

Part of the siteIncludedNot included
DatabaseAll tables: courses, users, grades, logs and settingsData of the tool_vault plugin itself, including its settings
FilesAll files from Moodle's file storageNothing
Data folderThe rest of the data folder (dataroot)Caches, temporary files, sessions, locks and the trash folder. You can exclude more, for example the antivirus quarantine or language packs.
config.phpSettings that are also normal site settingsThe file itself, and server settings: database connection, paths, temp folder, session handler
CodeNothingMoodle and add-on plugins: the new site has its own
Excluded pluginsNothingTheir data, with some limitations

Chunks and disk space

The Vault plugin reads the database, the files and the data folder through Moodle's APIs. Large amounts of data are split into chunks, archived and uploaded one by one. A restore downloads the archives one by one, extracts them and writes the data through Moodle's APIs.

  • Backups and restores need little free disk space: typically under 5 GB, even for a site of hundreds of GB.
  • If the connection fails, only the affected chunk is uploaded or downloaded again.
  • You don't need SSH, database tools or direct access to the database server.

Moving a site

On the old site

  1. Install tool_vault for the site's Moodle version. Make sure cron is running, unless you use the command-line scripts.
  2. Open Site administration > Server > Vault - Site migration.
  3. Add your API key. You can get one by signing in or signing up from inside the plugin.
  4. Back up, from Site administration or with the command-line script. On Pro and Enterprise you can add passphrase encryption.

On the new site

  1. Install a fresh Moodle site, or use an existing one: all its data will be overwritten. This is when you can choose a different database or file storage. Set up cron and install tool_vault for that Moodle version.
  2. Open Site administration > Server > Vault - Site migration.
  3. Add an API key from the same Vault account, and enable restores (disabled by default).
  4. Run a pre-check: Vault checks that the backup can be restored on this site, without changing anything.
  5. Restore. Your site will be placed in maintenance mode and the restore will happen in cron. You will only have access to the restore progress page. Remember, the whole site content will be overwritten.

Backups and restores started in Site administration run from cron, so you can close the browser. The command-line scripts don't need cron. The two sites can use different versions of the tool_vault plugin.

Restore pre-checks

Restore pre-checks always run as part of a restore. If any of them fails, the restore doesn't start, so you don't end up with an unusable Moodle site. You can also run the pre-checks separately.

CheckWhat it checksIf it fails
Moodle versionThe site runs the same or a newer Moodle than the backupUpgrade the site's Moodle code first
The standard Moodle upgrade can go from the backup's version to the site's versionTurn on "Automatically upgrade Moodle after restore": Vault upgrades the site to an intermediate version first, then runs the standard Moodle upgrade
Add-on pluginsEvery plugin in the backup is installed on the siteInstall them, or allow restoring with missing plugins. You can choose to automatically uninstall missing plugins during restore or do it manually later.
Each plugin on the site has the same or a newer version than in the backupUpdate plugins code and run Moodle upgrade
New plugins that only exist on this site but not in the backupThis is not a failure, only a heads-up that the plugins' data will be removed
Disk spaceThe site has enough temporary disk space to download and unpack one chunk at a timeFree up space

Backups have their own checks, for example which config.php settings will be included.

If a restore fails

Sometimes a restore fails partway through, for example when the cron task or PHP process is stopped or hits a time limit, the network connection drops, or the database reports an error.

If restore failed during the database restore stage, the database will be in an inconsistent state and such restore can not be resumed. You will need to re-install Moodle and repeat the restore again.

If restore failed after the database restore stage (during dataroot or files stages), it can be resumed.

If you are restoring exactly the same version of Moodle and all plugins, no upgrade is required, you can just log in to the site, open the page "Vault - Site migration", find the failed restore and press "Resume" button. Restore will continue during the next cron run.

If upgrade is pending, cron can not run and you will not be able to resume restore from the web interface. It is still possible to resume the restore from the command line. Example:

Moodle 5.1 and later:

sudo -u www-data php public/admin/tool/vault/cli/site_restore.php --resume

Moodle 5.0 and earlier:

sudo -u www-data php admin/tool/vault/cli/site_restore.php --resume

It is not recommended to run upgrade process and then resume the restore since occasionally upgrade process may modify the files.

Databases and file storage

You can restore into a different database engine (MySQL, MariaDB, PostgreSQL) or file storage. The plugin reads and writes files through Moodle's Files API, like Moodle itself, so it works with local disk, Amazon S3, Azure, Google Cloud, DigitalOcean, OpenStack or any other file storage plugin.

Upgrading across versions

Moodle's own upgrade only goes a few versions at a time. Vault restores a backup into any newer version, from 3.9 up to 5.3. Add-on plugins need versions that support the new Moodle.

From ↓ To →3.93.103.114.04.14.24.34.44.55.05.15.25.3
3.9Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with Vault
3.10Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with Vault
3.11Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and Vault*Moodle's own upgrade and Vault (see note *)*Moodle's own upgrade and Vault (see note *)Only with VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with Vault
4.0Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with VaultOnly with Vault
4.1Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and Vault**Moodle's own upgrade and Vault (see note **)**Moodle's own upgrade and Vault (see note **)Only with VaultOnly with VaultOnly with VaultOnly with Vault
4.2Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and Vault***Moodle's own upgrade and Vault (see note ***)***Moodle's own upgrade and Vault (see note ***)Only with VaultOnly with Vault
4.3Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultOnly with VaultOnly with Vault
4.4Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and Vault
4.5Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and Vault
5.0Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and Vault
5.1Moodle's own upgrade and VaultMoodle's own upgrade and VaultMoodle's own upgrade and Vault
5.2Moodle's own upgrade and VaultMoodle's own upgrade and Vault
5.3Moodle's own upgrade and Vault
Moodle's own upgrade and VaultOnly with Vault

Moodle's own upgrade needs at least * 3.11.8, ** 4.1.2, *** 4.2.3 as the starting point.

Sources: Moodle release notes on moodledev.io.

Show as text
  • Any version can be upgraded to a newer point release of the same version, for example 4.0.1 to 4.0.2.
  • From 3.9: Moodle's own upgrade up to 4.1. Vault: up to 5.3.
  • From 3.10: Moodle's own upgrade up to 4.1. Vault: up to 5.3.
  • From 3.11: Moodle's own upgrade up to 4.1, or up to 4.3 from 3.11.8. Vault: up to 5.3.
  • From 4.0: Moodle's own upgrade up to 4.3. Vault: up to 5.3.
  • From 4.1: Moodle's own upgrade up to 4.3, or up to 4.5 from 4.1.2. Vault: up to 5.3.
  • From 4.2: Moodle's own upgrade up to 4.5, or up to 5.1 from 4.2.3. Vault: up to 5.3.
  • From 4.3: Moodle's own upgrade up to 5.1. Vault: up to 5.3.
  • From 4.4: Moodle's own upgrade up to 5.3. Vault: up to 5.3.
  • From 4.5: Moodle's own upgrade up to 5.3. Vault: up to 5.3.
  • From 5.0: Moodle's own upgrade up to 5.3. Vault: up to 5.3.
  • From 5.1: Moodle's own upgrade up to 5.3. Vault: up to 5.3.
  • From 5.2: Moodle's own upgrade up to 5.3. Vault: up to 5.3.
  • From 5.3: point releases of 5.3 only, for now.

For the jumps only Vault can make, turn on "Automatically upgrade Moodle after restore" on the new site. Vault then upgrades the site to an intermediate version itself, and runs the standard Moodle upgrade from there.

PHP versions supported by each Moodle version

Moodle 4.1 and Moodle 5.x have no PHP version in common, so upgrading in place means changing PHP on the way. Restoring onto a new server avoids that.

Moodle ↓ PHP →7.27.37.48.08.18.28.38.4
3.9SupportedSupportedSupported
3.10SupportedSupportedSupported
3.11SupportedSupportedSupported
4.0SupportedSupportedSupported
4.1SupportedSupportedSupported
4.2SupportedSupported†Supported from 4.2.3
4.3SupportedSupportedSupported
4.4SupportedSupportedSupported
4.5SupportedSupportedSupported
5.0SupportedSupportedSupported
5.1SupportedSupportedSupported
5.2SupportedSupported
5.3SupportedSupported

† PHP 8.2 is supported from Moodle 4.2.3.

Sources: Moodle release notes on moodledev.io.

Show as text
  • Moodle 3.9: PHP 7.2, 7.3, 7.4
  • Moodle 3.10: PHP 7.2, 7.3, 7.4
  • Moodle 3.11: PHP 7.3, 7.4, 8.0
  • Moodle 4.0: PHP 7.3, 7.4, 8.0
  • Moodle 4.1: PHP 7.4, 8.0, 8.1
  • Moodle 4.2: PHP 8.0, 8.1, 8.2 (8.2 from Moodle 4.2.3)
  • Moodle 4.3: PHP 8.0, 8.1, 8.2
  • Moodle 4.4: PHP 8.1, 8.2, 8.3
  • Moodle 4.5: PHP 8.1, 8.2, 8.3
  • Moodle 5.0: PHP 8.2, 8.3, 8.4
  • Moodle 5.1: PHP 8.2, 8.3, 8.4
  • Moodle 5.2: PHP 8.3, 8.4
  • Moodle 5.3: PHP 8.3, 8.4

Security and compliance

PlanWhere backups are storedPassphrase encryption
Free, LightVault's storage in the EU, North America or Asia-PacificNo
ProVault's storage in Ireland, the UK, the US, Canada or AustraliaYes
EnterpriseYour own Amazon S3 bucketsYes
  • All data to and from Vault is encrypted in transit (TLS).
  • All data in Vault's storage is encrypted at rest (AES-256).
  • Passphrase encryption: the plugin turns your passphrase into a SHA-256 key, kept in the Moodle database only until the backup or restore finishes. The plugin uses the key only when it uploads to or downloads from Amazon S3, and checks that each link really points to Amazon S3 before sending it. The key is never sent to or stored on Vault's servers. A lost passphrase can't be recovered.
  • You choose the region when you start a backup, for example to comply with GDPR, or the one closest to your servers for faster transfers.
  • With your own S3 buckets (Enterprise), backups stay in your infrastructure, which helps with ISO 27001, SOC 2, HIPAA, FedRAMP, PCI DSS and similar requirements.
  • Vault's API and database, with your account and everything you see in the portal, are always in the EU (Ireland).
  • Your card and bank details go only to our payment processor: LMSCloud never sees or stores them.
  • The tool_vault plugin is open source: anyone can review it.
  • Every release of the plugin is reviewed for security with MDL Shield. MDL Shield

Vault vs traditional methods

Migrating sites using Vault has some advantages and disadvantages compared to the traditional database dump and file copy methods.

Vault is better because:

  • You need less disk space to perform backups and restores. Vault's intelligent algorithm uses minimal disk space during operations - typically under 5 GB, even if your site is hundreds of GB in total.
  • You don't need to be an expert in database tools or have direct access to the server (ssh, mysql client, etc.)
  • You don't need to worry about moving large amounts of data between servers, having transfers fail, or running out of storage space. In case of connection errors, chunks are re-uploaded/re-downloaded as needed.
  • You can restore to different database engines (mysql, mariadb, postgresql) and Moodle storage backends (local, S3, Azure, Google, Digital Ocean, Openstack).
  • It makes sharing backups with other people easy.

Traditional methods may be better because:

  • Performing a database dump is faster than copying data using the Moodle API assuming you know how to use the tools, are importing to the same database engine, and get it right on the first try.
  • Copying files locally can be faster than uploading to the cloud and downloading them again.
  • You don't need to install an additional Moodle plugin.

Command line

You can back up, restore and list your backups from the command line too, without cron. Add --help to any script to see its options. To hide Vault from Site administration entirely, turn on "Allow to perform site backup and restore from CLI only".

Moodle 5.1 and later

php public/admin/tool/vault/cli/site_backup.php --help
php public/admin/tool/vault/cli/list_remote_backups.php --help
php public/admin/tool/vault/cli/site_restore.php --help

Moodle 5.0 and earlier

php admin/tool/vault/cli/site_backup.php --help
php admin/tool/vault/cli/list_remote_backups.php --help
php admin/tool/vault/cli/site_restore.php --help

Video