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
$ cd askcos2_core
$ bash deploy.sh mongodump -d /some/absolute/dir/of/your/choiceThe 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
$ cd askcos2_core
$ make stop2 (Optional). If you want to drop all records in Mongo (e.g., for a clean recovery after data has become corrupted), run
$ 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
$ bash deploy.sh mongorestore -d /some/absolute/dir/of/your/choiceNote 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
$ make start