Options for Backing up DHIS2

Hi team,

I would like to know, what are backup options available for DHIS2 deployments with dhis2-tools?

Hello @Quoda
Please say more, But if you are talking about Backups when using dhis2-tools to deploy DHIS2, there are several backup options available to ensure data protection and disaster recovery. Here are some commonly used backup options for DHIS2 deployments with dhis2-tools:

  1. Database-level backups: This involves backing up the underlying database used by DHIS2, such as PostgreSQL or MySQL. You can use the native backup tools provided by the database management system to create regular backups of the database. For example, with PostgreSQL, you can use the pg_dump command to create a backup file.

  2. Filesystem backups: In addition to the database, it’s important to back up the DHIS2 data directory, which contains uploaded files, attachments, and resource files. You can schedule regular backups of this directory using filesystem-level backup tools or utilities like rsync to synchronize the data to another location.

  3. Docker volumes or Kubernetes persistent volumes: If you are using Docker or Kubernetes for your DHIS2 deployment, you can leverage the built-in volume management capabilities to create backups of the volumes associated with DHIS2. This ensures that both the database and data directory are backed up together.

  4. Automated backup scripts: You can create custom backup scripts that combine database and filesystem backups into a single process. These scripts can be scheduled using cron jobs or task schedulers to automate the backup process at regular intervals.

  5. Cloud storage backups: Consider utilizing cloud storage services, such as Amazon S3, Google Cloud Storage, or Azure Blob Storage, to store your backups securely in the cloud. You can configure your backup scripts to upload the backup files to the cloud storage provider.

  6. Offsite backups: It’s important to store backup files in an offsite location or a separate server to protect against data loss in case of server failures or disasters. You can use network file transfers or cloud storage services for offsite backup storage.

Remember to regularly test your backup and restore procedures to ensure they are working correctly. It’s also important to keep multiple copies of backups and implement a retention policy to manage the backup files effectively.

The choice of backup option depends on your specific deployment setup and infrastructure. It’s recommended to consult the dhis2-tools documentation and the documentation of your chosen database management system and backup tools for detailed instructions and best practices regarding backups.

There is a post we have just shared have a look at this link on this post - How do I backup and restore my DHIS2 Database instance - #2 by moses_mwale

2 Likes

Hi @moses_mwale,

Thanks so much for taking time to develop this breakdown of options for DHIS2 backup.
Exactly what I wanted to know! Very helpful.

2 Likes

@moses_mwale If I used the pg_dump command to create dump file of my db, and trying to inject the the dump file into a new instance, what I expect is to have dashboards, users, TEIs, etc from the previous instance working in the new instance. Am I right?

I tried this out; injecting the dump file into a new instance but I do not get my expected results. Is there something I should know? Thanks for your help

Hi @moses_mwale

We would to automate backups using scripts and cron job. I were wondering if you could share scripts to backup DHIS 2 file system using rsync. Our DHIS implementation is through LXD/LXC containers.
I have read your post [How do I backup and restore my DHIS2 Database instance ]. The question is: is the way to backup Postgres Database described in the post the same even when the implementation is through LXC containers? if not, how should we proceed?

Thanks

I know this topic is closed but would like to add my 5 cents on it.

I would advise

  • to make postgres backups at db level, and not (only) file system level
  • to not put all your eggs in a single basket :
    • you can mix backup solutions (ex a pg_dump every week or every day + a proprietary cloud backup (rds snapshots))
    • copy your backups to other locations (ex in another cloud provider or another physical site) : have a look at https://restic.net/ or similar tool

when restoring

  • restart the dhis2 server once restored
    • make sure the dhis2 version matches the version of the backup you restored
  • make sure pg_restore is not showing warnings
    • lately I restored a backup but some sqlviews where not dropped (introduced in one of the system for test) causing some dhis2 tables to not be restored
    • search for messages like
      cannot drop table public.xxx because other objects depend on it
3 Likes