3.3.7 Automated backup and restore / Optional external backups

Every day OpenCRVS automatically backs up all databases to the following directories on the manager node. Every 7 days the data is overwritten to save disk space. The Ansible playbook sets this up as an option in this step. If you configured a separate backup server and used the external backup server optional SSH properties in the Ansible script in step 3.3.2 Install dependencies, these files are additionally backed up to that server in the middle of the night. We recommend using a dedicated backup server in production.
We highly recommend that once a week, these files should be saved to a password protected and encrypted external harddrive and stored in a secure and approved location.
Hearth, OpenHIM and the other databases will be saved in mongo .gz zip files using the date of the backup here:
Elasticsearch snapshot files and indices are saved here. The entire folder is required for all snapshots regardless of the date:
InfluxDB backup files are saved into a date named folder here:

To perform a restore, ensure that you have backup files in the day's folders you wish to restore from. If this is a new environment, you would need to copy the backed up files and folders into the locations using scp or rsync. You should only restore to a clean installation of OpenCRVS.
Backup files:
All the Mongo backup zips you would like to restore from must exist in /data/backups/mongo folder named like this:
The Elasticsearch backup folder /data/backups/elasticsearch must exist with all previous snapshots and indices.
The InfluxDB backup files must exist in the /data/backups/influxdb/{date} folder
  1. 1.
    SSH into the manager node
  2. 2.
    Make sure you are a root user
  3. 3.
    cd to the /opt/opencrvs/infrastructure directory
  4. 4.
    Ensure that your database secrets are available as environment variables. You can do this by running:
export ELASTICSEARCH_ADMIN_PASSWORD=<your elastic password> \
export MONGODB_ADMIN_USER=< your mongo username> \
export MONGODB_ADMIN_PASSWORD=<your mongo password>
5. Run the following script as root but beware that ALL DATA WILL BE REPLACED BY YOUR BACKUP DATA
./emergency-restore-metadata.sh <day of the week to restore from> <number of server replicas: 1 3 or 5>
Copy link
On this page
Backup process
Restore process