Backup & Restore
- 1 🔄 How It Works
- 2 Configuration
- 2.1 🔧 Environment Variables
- 2.2 Volumes and Labels
- 2.3 Usage
- 2.3.1 Restore
- 2.4 References
This project provides out-of-the-box backup and restore functionality for your OpenMRS deployment, powered by the robust Restic tool. This enables you to back up and restore your application data using a wide variety of storage backends supported by Restic, such as local disk, S3, Azure, Google Cloud Storage, and more.
🔄 How It Works
Backup and restore are managed by dedicated Docker Compose services using the
mekomsolutions/restic-compose-backupandmekomsolutions/restic-compose-backup-restoreimages.The backup service periodically snapshots your data volumes and database, storing them in your configured Restic repository.
The restore service can be used to recover your data from a specific snapshot.
Configuration
🔧 Environment Variables
You can configure backup and restore behavior using the following environment variables in your .env file or directly in your Compose files:
Variable | Description |
|---|---|
| The Restic repository URL (e.g., local path, s3, etc.) |
| Password for the Restic repository |
| Number of daily snapshots to keep |
| Number of weekly snapshots to keep |
| Number of monthly snapshots to keep |
| Number of yearly snapshots to keep |
| Log verbosity (e.g., |
| Cron schedule for automatic backups (e.g., |
| (Restore only) The snapshot ID or tag to restore |
| Local directory for storing backup repository (default: |
Volumes and Labels
The
backendanddbservices are labeled and configured to include their data volumes in the backup.Additional volumes (e.g., for configuration checksums, person images, complex obs) are also included and labeled for backup.
Usage
Restore
To restore from a backup:
Set the
BACKUP_PATH,RESTIC_PASSWORD, andRESTIC_RESTORE_SNAPSHOTenvironment variables.Start the restore service:
docker compose -f docker-compose.yml -f docker-compose-restore.yml up -dThis will restore the specified snapshot to the appropriate volumes. The backend and db services are configured to wait for the restore to complete before starting.
IMPORTANT
The restore process will leave a restore container that will block the backup process. To clean up the restore container, run the following command:
docker compose -f docker-compose.yml -f docker-compose-restore.yml rm restore
docker compose -f docker-compose.yml -f docker-compose-restore.yml exec backup restic unlock -v