Skip to content

fix: dhis2-restoredb precheck target DB and idempotent container stop/start - #106

Merged
tkipkurgat merged 1 commit into
mainfrom
fix/dhis2-restoredb-idempotency
Sep 29, 2026
Merged

tkipkurgat merged 1 commit into
mainfrom
fix/dhis2-restoredb-idempotency

Conversation

@tkipkurgat

Copy link
Copy Markdown
Collaborator

Summary

  • The restore pre-check query didn't target the postgres maintenance database, causing false failures before the restore even started.
  • The container stop/start step (added so nothing holds open connections during restore) unconditionally called lxc stop, which errored ("The instance is already stopped") if the DHIS2 instance container was already stopped, aborting the whole restore. Fixed by checking the container's actual state via lxc list --format csv -c s first, and only stopping (and trap-restarting) it if it was actually running.
  • Removes backups/files/dhis2-restoredb, an orphaned duplicate of the same script with neither fix applied and no remaining references in the backups role's tasks.

Test plan

  • Run dhis2-restoredb against a running instance container - confirm it stops the container, restores, and restarts it
  • Run dhis2-restoredb against an already-stopped instance container - confirm it no longer errors out and completes the restore
  • Confirm the precheck no longer false-fails

…/start

Two bugs in the restore scripts (pre-install/files/dhis2-restoredb,
mirrored in backups/files/ssh/dhis2-restoredb):

1. The pre-check query didn't target the "postgres" maintenance
   database, causing false failures before the restore even started.

2. The container stop/start step (added so nothing holds open
   connections during restore) unconditionally called `lxc stop`,
   which errored ("The instance is already stopped") if the DHIS2
   instance container was already stopped, aborting the whole
   restore. Fixed by checking the container's actual state via
   `lxc list --format csv -c s` first, and only stopping (and
   trap-restarting) it if it was actually running - otherwise leaving
   it as-is.

Also removes backups/files/dhis2-restoredb, an orphaned duplicate of
the same script with neither fix applied and no remaining references
in the backups role's tasks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@tkipkurgat
tkipkurgat merged commit 5c78c0b into main Sep 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant