Bahmni Backup & Restore - How do they work ?

I’m creating this post to better understand the mechanism behind the scene. This is my bahmni-backrest.conf file content

openmrs:
  path: /bahmniData/data/openmrs/
  retention_limit: 2
  restore_path: /bahmniData/data/openmrs/

postgres:
  path: /var/lib/pgbackrest
  retention_limit: 5

bahmni_reports:
  path: /bahmniData/data/reports/
  retention_limit: 2
  restore_path: /bahmniData/data/reports/

When I run this command to backup all the stuff I have them stored under the given path.

If I copy all these folders to the new server under the restore_path and run the restore command, I won’t get the data on the new server.

This the backup log file

2023-01-03 01:10:34.266 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/2613 (0B, 100%)
2023-01-03 01:10:34.271 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/2611_vm (0B, 100%)
2023-01-03 01:10:34.277 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/2611 (0B, 100%)
2023-01-03 01:10:34.282 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/2604_vm (0B, 100%)
2023-01-03 01:10:34.287 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/2604 (0B, 100%)
2023-01-03 01:10:34.293 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/2336_vm (0B, 100%)
2023-01-03 01:10:34.298 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/2336 (0B, 100%)
2023-01-03 01:10:34.303 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/2328_vm (0B, 100%)
2023-01-03 01:10:34.308 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/2328 (0B, 100%)
2023-01-03 01:10:34.313 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/1418_vm (0B, 100%)
2023-01-03 01:10:34.317 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/1418 (0B, 100%)
2023-01-03 01:10:34.322 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/1417_vm (0B, 100%)
2023-01-03 01:10:34.326 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/1417 (0B, 100%)
2023-01-03 01:10:34.331 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/13192 (0B, 100%)
2023-01-03 01:10:34.338 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/13190 (0B, 100%)
2023-01-03 01:10:34.344 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/13187 (0B, 100%)
2023-01-03 01:10:34.349 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/13182 (0B, 100%)
2023-01-03 01:10:34.354 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/13177 (0B, 100%)
2023-01-03 01:10:34.360 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/13172 (0B, 100%)
2023-01-03 01:10:34.366 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/13167 (0B, 100%)
2023-01-03 01:10:34.371 P01   INFO: local process 1 stop for db-1
2023-01-03 01:10:34.372 P01   INFO: backup file /var/lib/pgsql/9.6/data/base/1/13162 (0B, 100%)
2023-01-03 01:10:34.696 P00   INFO: full backup size = 384.3MB
2023-01-03 01:10:34.696 P00   INFO: execute non-exclusive pg_stop_backup() and wait for all WAL segments to archive
2023-01-03 01:10:35.799 P00   INFO: backup stop archive = 00000008000000060000004C, lsn = 6/4C01FCC8
2023-01-03 01:10:37.672 P00   INFO: new backup label = 20230103-011036F
2023-01-03 01:10:37.964 P00   INFO: backup command end: completed successfully
2023-01-03 01:10:37.965 P00   INFO: expire command begin 1.12: --log-level-console=info --repo-path=/var/lib/pgbackrest --retention-archive=5 --retention-full=5 --stanza=bahmni-postgres
2023-01-03 01:10:37.987 P00   INFO: full backup total < 5 - using oldest full backup for archive retention
2023-01-03 01:10:37.991 P00   INFO: expire command end: completed successfully

This leads me to a confusion. I just want to know I’m doing wrong ? I have been struggled for many months now to migrate this server

Hello @gabykant If I understand correctly the new machine where you are trying the restore the database has the above mentioned bahmni-backrest.conf file in /etc/ folder and the backup files are in the /bahmniData/data/reports/ path ?

Hi @binduak the above mentionned bahmni-backrest.conf is the old server. The new server has the default bahmni-backrest.conf values:

openmrs:
  path: /data/openmrs/
  retention_limit: 2
  restore_path: /data/openmrs/

postgres:
  path: /var/lib/pgbackrest/
  retention_limit: 2

bahmni_reports:
  path: /data/reports/
  retention_limit: 2
  restore_path: /data/reports/

sync:
  host:
  path:
  user:

I have zipped the old backup folder from /bahmniData/data/openmrs and /var/lib/pgbackrest to the new server folder respectively /data/openmrs/ and /var/lib/pgbackrest/

After that when I run the restore command from the new server everything goes well. But I can’t access some menus (Sales, Point of Sales and Inventory) from Odoo (error related to the Bahmni Module). I tried then to Upgrade all Bahmni modules from the Apps and the same errors appears. Refer to this thread here .

If I uninstall and reinstall Bahmni Sale module, I can access thoses menus now but all the data are lost.

I think there is something going wrong with the restore command. Either it does not consider backing up some data or I don’t know