Skip to content

Data backup and recovery

Backup

It is important to back up the data of users and of results, regularly and before major updates. The steps below assumes the default naming of the Mongo volume, i.e., deploy_askcosv2_mongo_data. If it has been configured to a different name, please modify accordingly in deploy.sh. Save the Mongo dump with

shell
$ cd askcos2_core
$ bash deploy.sh mongodump -d /some/absolute/dir/of/your/choice

The ASKCOS services on the machine do not need to be stopped during dumping. Once the script finishes execution, you will have the compressed Mongo dump at /some/absolute/dir/of/your/choice/mongo_dump.gz.

Recovery

In our experience, there might be some weird outcomes if there are other services writing to Mongo during restoration. It is therefore recommended to stop all services, restore Mongo, and then restart the services.

1. Stop the services by

shell
$ cd askcos2_core
$ make stop

2 (Optional). If you want to drop all records in Mongo (e.g., for a clean recovery after data has become corrupted), run

shell
$ bash deploy.sh run-single-mongo-command "results" "db.dropDatabase()"
$ bash deploy.sh run-single-mongo-command "askcos" "db.dropDatabase()"

Warning: this drops everything (users, results, buyables, reactions) in the DB.

3. Restore the data with

shell
$ bash deploy.sh mongorestore -d /some/absolute/dir/of/your/choice

Note that mongorestore runs in insert mode (since it has no support for upsert), it will therefore not overwrite any existing results if not dropped from Step 2. There might be KeyErrors in this case but can generally be safely ignored.

4. Restart ASKCOS with

shell
$ make start

Released under the MIT License.