Its a standard practice to have multiple environments in a ‘pipeline’ leading to production at the end in the IT industry and similarly almost all Moodle users may have multiple Moodle environments for testing and development of new features in Moodle.
The developers/testers also need real data to test the new features but there are many downsides for that also like:
- Usually production can be quite massive, we don’t need or want it all and disk space can be a pain with multiple copies.
- There may be sensitive data we don’t want to expose to developers or testers, eg personal data, grades, uploaded assignments etc
- Moodle is integrated with 3rd party systems and we don’t want test systems interacting with real systems, eg sending emails, or touching assignments in Turnitin etc, ie we want to remove any API keys and other related config
- Refresh the Moodle database,
- Reduce the size of the data
- Remove anything sensitive
The plugin consists of multiple ‘cleaners’ which process different types of data in moodle. Each one can be enabled individually and may have additional config settings.
The plugin also have multiple safeguards to prevent it from accidentally running in the production environment like:
- It can only be run from the CLI. There is no GUI.
- We store the hostname in the cleaning configuration data. If the hostname matches production, Data Cleaner will not run. If this data is missing then it will not run.
- Typically a refreshed database will be from a nightly snapshot and so the data should be slightly stale. If a non admin user has logged in recently, that’s a sign this moodle is being used, and the Data Cleaner will not run.
- If cron has run recently, Data Cleaner will not run. This should only be run on a data washing instance, cron should not be needed here.
- It can only be run if and only if a ‘local_datacleaner_allowexecution = true;’ has been added to config.php
You can download the Data Cleaner plugin from the Moodle plugins database here. The plugin comes up with a good documentation along with it which can be referred to find more details about the other configuration options of the plugin.
Please note that this plugin is only meant for Moodle Site Administrators and Developers and should be used on the sandbox sites first before using on production environments. We will not be responsible for any loss arise due to usage of this plugin.