PostgreSQL High Availability synchronization and failover automation tool
ha-syncgen is a CLI tool for declaratively managing PostgreSQL high availability (HA) clusters. It generates scripts, configuration files, and systemd services to automate primary-replica setups, health checks, and failover. The tool is powered by a simple YAML configuration and is designed for reliability, transparency, and easy integration with your infrastructure workflows.
Key Features:
- Declarative YAML configuration for cluster topology and options
- Script and config generation for all nodes (primary and replicas)
- Systemd integration for health checks and failover automation
- Automatic failover to replica on primary failure
- Observability: Datadog integration and extensible monitoring
- Cross-platform: Linux, macOS, and Windows support
- Install
go install github.com/HasithDeAlwis/ha-syncgen@latest
# or build from source
go build -o syncgen ./- Create/Edit your config
See
configuration.mdxfor all options and examples. - Validate your config
syncgen validate cluster.yaml- Generate scripts
syncgen build cluster.yaml- Deploy
- Copy scripts from
generated/to your servers - Run setup scripts and enable systemd services
See CLI Reference for all commands, flags, and usage examples.
For AWS/dev automation and advanced workflows, see devenv/aws/main.go.
- Edit docs in
docs/content/docs/ - PRs welcome!
GNU GPL 3.0
- Declarative YAML configuration — Define your cluster, nodes, and options in a single file
- Script & config generation — All necessary setup, health, and failover scripts are generated for you
- Systemd integration — Health checks and failover logic run as systemd services/timers
- Automatic failover — Detects primary failure and promotes a replica
- Observability — Datadog integration and extensible monitoring hooks
- Cross-platform — Works on Linux, macOS, and Windows
-
syncgen deploycommand for automated deployment -
syncgen statuscommand for cluster monitoring -
syncgen promotecommand for manual failover - Advanced validation and error handling
- Integration tests with real PostgreSQL instances
- Docker support for development/testing