Running Bahmni Lite with DB backup from cloud (Docker)
This page documents how to take a DB Backup of your OpenMRS / EMR DB from Kubernetes environment (running on cloud), build a docker image with this DB, and then run Bahmni docker compose with the restored database.
WARNING: If you are working with production data, please be very careful how you handle it, who has access to it, and where you share/keep it. It is illegal to make private patient data available to people without authorisation in most countries!
Repositories
🔸 Bahmni Lite - India based with ABDM integration
🔸 Bahmni Scripts - to build DB for openMRS
Setup
🔹 Git clone the respective Bahmni Lite repository
🔹 Git clone the Bahmni Scripts repository
🔹 Install Docker
DB backup from Kubernetes/AWS
We ran Bahmni Lite on AWS/Kubernetes. So the following setup will extract DB dump based on Kubernetes commands.
Get into the openMRS kubernetes pod
kubectl exec -it openmrs<POD_ID> -n <namespace> -- bash
2. Navigate to the openmrs/data
folder and zip the configuration_checksum
folder (which is used by Initializer module to determine if an initializer entry has run or not run).
# install zip
yum install zip
# Navigate to openmrs/data directory
cd /openmrs/data
# Zip the checksums folder
zip -r configuration_checksums.zip configuration_checksums
3. Backup the DB as a SQL dump
# Install mysql cli
yum install mysql
# Export the current live DB as a sql dump to the pod
mysql -u username -p database_name > omrsdb.sql
# Provide password and press Enter
# Exit Mysql
Exit
4. Note down the Database details
Keep a note of the above DB details and maintain them securely until the setup is completed successfully
5. Copy the files to local machine
Build the DB in Docker
Navigate to
~/bahmni-scripts/demo/db-backups/1.0.0-lite/mysql5.7/resources
2. Delete the files present in this directory
3. Copy and paste the files exported from the pod i.e configuration_checksums.zip
and omrsdb.sql
to this directory
4. Navigate back to the mysql5.7 directory and replace the Dockerfile contents with the following code:
Apple M1 Chip (Mac)
Others (Linux)
5. Navigate to bahmni-scripts root directory and execute the following docker command (note the TAGNAME should be set to some specific value. e.g my-build-1):
Config the environment and docker compose
Navigate to the
bahmni-docker/bahmni-lite
orbahmni-india-package
directory where thedocker- compose.yml
is present
2. Add the openMRS DB details captured earlier in DB backup extraction to the .env file and save it. Ensure the OPENMRS_DB_IMAGE_NAME
is pointing to the newly created docker image (as generated in the previous step).
Invoke Bahmni Lite
Bring up Bahmni through Docker compose
2. Wait for openmrs to load with all the required indexes
3. Enter “http://localhost/openmrs” in browser and verify openMRS is up
4. Navigate to “http://localhost/” and start using Bahmni (this should now run with the new DB)
The Bahmni documentation is licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)