Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
PostgreSQL High Availability & Disaster Recovery
New
9 students

PostgreSQL High Availability & Disaster Recovery

Build production-ready PostgreSQL HA with Patroni, etcd and HAProxy, test failover, pgBackRest, PITR and DR recovery
Created byAgus Kurniawan
Last updated 11/2026
English
English

What you'll learn

  • Build a production-style PostgreSQL High Availability cluster using streaming replication, Patroni, etcd, and HAProxy.
  • Configure and troubleshoot PostgreSQL streaming replication, WAL flow, replication lag, and standby synchronization.
  • Perform manual and automatic PostgreSQL failover, promote standby servers, recover failed nodes, and prevent split-brain scenarios.
  • Connect a real application to PostgreSQL through HAProxy and validate application continuity during database failover.
  • Configure PostgreSQL backups with pgBackRest and WAL archiving, then recover data using Point-in-Time Recovery (PITR).
  • Design an isolated PostgreSQL Disaster Recovery environment and replicate data between primary and DR sites.
  • Simulate a complete primary-site outage, promote the DR database, cut over the application, and validate production recovery.
  • Measure and evaluate RPO, RTO, replication lag, application downtime, and potential data loss during HA and DR scenarios.

Course content

8 sections • 64 lectures • 7h 38m total length
  • PostgreSQL HA & Disaster Recovery: What You Will Build2:41
  • High Availability vs Backup vs Disaster Recovery2:48
  • RPO, RTO, Failover, Switchover, and Failback4:13
  • Inside the PostgreSQL HA/DR Architecture4:32
  • Why a PostgreSQL DR Site Must Be Isolated3:38
  • Scripts and Slides0:02

Requirements

  • Basic PostgreSQL administration
  • Basic SQL
  • Linux command-line operations
  • Basic TCP/IP networking concepts

Description

PostgreSQL can replicate data. That does not automatically make it highly available, and it certainly does not make it disaster-ready.

In production, the real questions begin when something fails. What happens when the PostgreSQL primary suddenly disappears? How quickly can another node take over? What happens to active applications during failover? Can the cluster survive the loss of an etcd member? What if replication is delayed? What if the database is healthy but someone deletes critical production data? And what happens when the problem is no longer a single server, but the loss of an entire site?

This course is built around those questions.

You will create a production-style PostgreSQL High Availability and Disaster Recovery environment using PostgreSQL 18, streaming replication, Patroni, etcd, HAProxy, pgBackRest, WAL archiving, and Point-in-Time Recovery. The emphasis is not on memorizing configuration files. You will build the environment, deliberately introduce failures, observe how PostgreSQL behaves, and then recover it.

The course starts with PostgreSQL physical streaming replication so you understand what is happening underneath the HA layer. You will configure primary and standby servers, build replicas with pg_basebackup, inspect WAL movement, measure replication lag, stop replicas, and observe the operational consequences. You will then perform failover manually before introducing automation, so Patroni does not become a black box.

From there, you will build a three-node PostgreSQL HA cluster with Patroni and etcd, configure quorum and leader election, and place HAProxy in front of the database as a stable application endpoint. A real ASP.NET Core Minimal API is used to continuously write data into PostgreSQL, allowing you to see what an application actually experiences when the primary fails and Patroni promotes another node.

You will intentionally stop the PostgreSQL primary, restart failed servers, remove an etcd member, recover cluster nodes, and measure application interruption during failover. The objective is not simply to see that failover works, but to understand what happens before, during, and after it.

High Availability also does not protect against every type of data loss. For that reason, the course includes a separate backup and recovery workflow using pgBackRest and WAL archiving. You will create and validate PostgreSQL backups, deliberately delete application data, and recover the database to a specific point in time using PITR.

The final part of the course moves beyond local HA into real Disaster Recovery. The primary PostgreSQL environment and DR environment are placed on separate private networks to represent different failure domains. You will build a DR replica, monitor replication lag, simulate the loss of the complete primary site, determine the last transaction that reached the DR system, promote the DR database, manually cut over the application, and validate production transactions on the recovery site.

You will also examine the operational decisions behind RPO, RTO, failover, switchover, failback, replication lag, and potential data loss. By the end of the course, you will have worked through the complete path from normal PostgreSQL operation to server failure, automatic HA failover, data recovery, site-level disaster, DR promotion, and recovery planning.

This is an intermediate, hands-on course for PostgreSQL administrators, DBAs, DevOps engineers, SREs, platform engineers, and infrastructure engineers who already understand PostgreSQL basics and want to learn how PostgreSQL behaves when production systems fail.

The course follows one practical principle throughout:


Build it. Break it. Observe it. Fail over. Recover it.

If your goal is to move beyond “PostgreSQL replication is running” and understand how to design, test, and operate PostgreSQL High Availability and Disaster Recovery in realistic failure scenarios, this course is designed for that.

Who this course is for:

  • PostgreSQL administrators and DBAs
  • DevOps engineers
  • Site Reliability Engineers (SREs)
  • Platform engineers
  • Infrastructure engineers
  • Backend engineers responsible for production PostgreSQL systems
  • Technical professionals who already understand PostgreSQL basics and want to learn production HA and DR