How samirdash4u/dr_dc_switchover works
Purpose and operating model
This is a shell-script automation repository for Appsone/HEAL DC-to-DR switchover. It supports isolated environments through an offline artifact boundary: DC exports state, an operator securely transfers a tarball, and DR restores or validates that state. DNS switching remains external/manual.
Primary entry points are the ordered DC and DR scripts, with a likely top-level coordinator at orchestrator.sh. Certificate import is separately invoked through importcert.sh.
Configuration and shared runtime
The scripts are configuration-driven and intended to use the same configuration in both sites:
• config/config.sh supplies database, backup/restore, and environment parameters.
• config/dcnomadjoblist.txt and config/drnomadjoblist.txt define expected Nomad workloads per site.
• config/workerentry.sh defines connector database endpoint updates.
• common/logger.sh and common/utils.sh provide shared script behavior.
The runtime is Bash/shell on hosts with access to local DC or DR infrastructure and command-line clients for the platform services.
DC readiness gate
The DC pipeline begins with prerequisite validation in dc/01_prerequisites.sh. This is the safety boundary before producing a switchover bundle: it checks availability/readiness of Consul, Nomad, MySQL, OpenSearch, disk capacity, and required Nomad jobs, using configured expected job lists such as config/dcnomadjoblist.txt.
Failure here should prevent downstream export stages from producing a potentially incomplete recovery artifact.
DC export pipeline
DC state is collected in explicit ordered stages:
• Database backup: dc/02_db_dump.sh
• Consul KV export: dc/03_consul_export.sh
• Nomad job/image definition export: dc/04_nomad_export.sh
• Bundle construction: dc/05_package_artifacts.sh
These stages transform live platform state into portable files, then package them as a timestamped switchover_bundle_<timestamp>.tar.gz. The tarball is the repository’s principal cross-environment contract; no direct DC-to-DR network flow is required or assumed.
Transfer boundary
Artifact movement is intentionally outside automation. An operator transfers the generated bundle to DR through an approved secure mechanism. This separates DC credentials and live service access from DR application, and allows the two sites to execute independently.
DR application and reconciliation pipeline
DR processing is also ordered:
• DR readiness validation: dr/01_prerequisites.sh
• Artifact extraction: dr/02_unpack.sh
• Database restore: dr/03_db_restore.sh
• Connector receiver endpoint rewrite: dr/04_update_entry.sh
• Consul comparison/reconciliation reporting: dr/05_consul_match.sh
• Nomad image/version comparison reporting: dr/06_nomad_match.sh
dr/03_db_restore.sh applies the database portion of the transferred state. The later Consul and Nomad stages are described as identifying missing keys and job image mismatches, making them validation/reconciliation boundaries rather than an assumed blind overwrite of DR runtime configuration.
Endpoint and certificate operations
Connector endpoint updates are data-level DR adaptations controlled by config/workerentry.sh and applied by dr/04_update_entry.sh. They support a default endpoint or database-specific overrides while preserving protocol/path behavior.
Certificate handling is an adjacent operational capability: importcert.sh uses certificate definitions in config/certs.sh to fetch/import certificates, skip existing aliases, or overwrite them. It is independent of the artifact pipeline but may be required for service connectivity after switchover.
Main entry points: dc/01_prerequisites.sh DC readiness gate · dr/01_prerequisites.sh DR readiness gate · 02_unpack.sh Extract bundle · 04_update_entry.sh Rewrite connector endpoints
Components 20
Shared runtime
- Shared configuration · Database, backup, restore, and environment parameters.
config/config.sh - DC expected jobs
config/dcnomadjoblist.txt - DR expected jobs
config/drnomadjoblist.txt - Shared shell runtime · Logging and utility behavior used by automation scripts.
common/logger.sh
DC export
- DC readiness gate · Blocks export unless platform services, capacity, and expected jobs are ready.
dc/01_prerequisites.sh - Database backup
dc/02_db_dump.sh - Consul KV export
dc/03_consul_export.sh - Nomad definitions export
dc/04_nomad_export.sh - Bundle artifacts · Creates the timestamped switchover tarball.
dc/05_package_artifacts.sh
Offline transfer
- Switchover bundle · Portable DC state contract for DR.
- Secure operator transfer · Approved offline movement between sites.
DR restore and reconciliation
- DR readiness gate
dr/01_prerequisites.sh - Extract bundle
dr/02_unpack.sh - Database restore · Applies the transferred database state.
dr/03_db_restore.sh - Connector endpoint rules · Default and database-specific DR endpoint updates.
config/workerentry.sh - Rewrite connector endpoints
dr/04_update_entry.sh - Consul reconciliation report · Identifies missing keys without assuming blind overwrite.
dr/05_consul_match.sh - Nomad version report · Identifies job image and version mismatches.
dr/06_nomad_match.sh
Certificate operations
- Certificate definitions
config/certs.sh - Certificate import · Imports, skips, or overwrites certificate aliases independently of switchover.
importcert.sh
Connections 20
- Shared configuration → DC readiness gate: configures
- DC expected jobs → DC readiness gate: expected workloads
- Shared shell runtime → DC readiness gate: shared behavior
- DC readiness gate → Database backup: gate passes
- Database backup → Consul KV export: then
- Consul KV export → Nomad definitions export: then
- Nomad definitions export → Bundle artifacts: then
- Bundle artifacts → Switchover bundle: produces
- Switchover bundle → Secure operator transfer: handed to
- Secure operator transfer → Extract bundle: delivers at DR
- Shared configuration → DR readiness gate: configures
- DR expected jobs → DR readiness gate: expected workloads
- Shared shell runtime → DR readiness gate: shared behavior
- DR readiness gate → Extract bundle: gate passes
- Extract bundle → Database restore: database artifact
- Database restore → Rewrite connector endpoints: then
- Connector endpoint rules → Rewrite connector endpoints: endpoint rules
- Rewrite connector endpoints → Consul reconciliation report: then
- Consul reconciliation report → Nomad version report: then
- Certificate definitions → Certificate import: certificate definitions