Pg_rewind in Postgresql-1
Pg_rewind in Postgresql-1
Instead of performing a full base backup, pg_rewind quickly brings a node back in sync by
identifying and copying only the necessary changes, making the process much faster and more
efficient.
Benefits of pg_rewind
Benefit Description
Reduces Storage and Network Since only changed data is copied, it minimizes storage and
Overhead network bandwidth usage.
Seamless Integration with Works well with streaming replication and automated failover
Replication and Failover tools like Patroni, Repmgr, or Pacemaker.
• After a failover where the original primary has diverged from the new primary.
• The diverged node must have been a part of the same cluster.
Instead of removing all data, we ensure the data directory is in a clean state for pg_rewind.
mv /var/lib/pgsql/data /var/lib/pgsql/data_old
mkdir -p /var/lib/pgsql/data
This guide ensures a failed primary node can be safely reintegrated as a standby in a PostgreSQL
HA setup without requiring a full backup restore.