{% load i18n %}

๐Ÿ” {% trans "Replication" %}

{% trans "readiness ยท WAL position ยท standbys ยท slots" %}

{% include "partials/_banner.html" %}
{% trans "Readiness" %} {% if status.ready %} {% trans "ready for a standby" %} {% else %} {% trans "not accepting standbys" %} {% endif %}
{% trans "role" %}
{% if status.is_standby %}{% trans "standby (in recovery)" %}{% else %}{% trans "primary" %}{% endif %}
{% trans "current LSN" %}
{{ status.current_lsn|default:"โ€”" }}
wal_level
{{ status.wal_level }}
max_wal_senders
{{ status.max_wal_senders }}
max_replication_slots
{{ status.max_replication_slots }}
archive_mode
{{ status.archive_mode }}
{% blocktrans %}A standby needs wal_level โ‰ฅ replica and max_wal_senders > 0.{% endblocktrans %}
{% trans "1 ยท Make the primary ready" %}
{% if recipe.ready %}

{% trans "โœ“ Already configured to accept a standby." %}

{% else %}

{% trans "Set these on the primary, then restart it (each needs a full restart):" %}

{% for param, val in recipe.conf_changes %}
{{ param }} {{ val }}
{% endfor %}
{% endif %}
{% trans "2 ยท Create a replication slot" %}
{% if recipe.slot_exists %}

{% blocktrans with name=recipe.slot_name %}Reusing the existing physical slot {{ name }}.{% endblocktrans %}

{% else %}

{% blocktrans with name=recipe.slot_name %}No physical slot yet โ€” create {{ name }} (so the primary keeps WAL for the standby):{% endblocktrans %}

{{ recipe.create_slot_sql }}
{% endif %}
{% trans "3 ยท Clone to the standby host" %}

{% trans "Run this on the new standby (an empty data dir). -R writes its standby config for you:" %}

{{ recipe.basebackup_cmd }}

{% trans "primary_conninfo it will write:" %} {{ recipe.primary_conninfo }}

{% blocktrans with host=recipe.primary_host port=recipe.primary_port %}โš  The standby must be able to reach {{ host }}:{{ port }} over the network, and authenticate โ€” set the password via PGPASSWORD or ~/.pgpass (never in the config). This is a starting point; see your platform's docs for production (TLS, auth).{% endblocktrans %}

{% trans "Standbys" %} pg_stat_replication
{% if standbys %} {% for s in standbys %} {% endfor %}
PID {% trans "Client" %} {% trans "State" %} {% trans "Sync" %} {% trans "Lag" %} {% trans "Replay lag" %}
{{ s.pid }} {{ s.app|default:"โ€”" }} {{ s.client|default:"" }} {{ s.state|default:"โ€”" }} {{ s.sync_state|default:"โ€”" }} {% if s.lag_bytes is not None %}{{ s.lag_bytes }} B{% else %}โ€”{% endif %} {{ s.replay_lag_human|default:"โ€”" }}
{% else %}

{% trans "No standby connected." %}

{% endif %}
{% trans "Slots" %} pg_replication_slots
{% if slots %} {% for sl in slots %} {% endfor %}
{% trans "Name" %} {% trans "Type" %} {% trans "Active" %} {% trans "Restart LSN" %} {% trans "Retained WAL" %} {% trans "Actions" %}
{{ sl.name }} {{ sl.slot_type }}{% if sl.database %} {{ sl.database }}{% endif %} {% if sl.active %} {% trans "active" %} {% else %} {% trans "inactive ยท pins WAL" %} {% endif %} {% if sl.wal_status and sl.wal_status != 'reserved' %} {{ sl.wal_status }} {% endif %} {{ sl.restart_lsn|default:"โ€”" }} {% if sl.retained_bytes is not None %}{{ sl.retained_bytes|filesizeformat }}{% else %}โ€”{% endif %}
{% else %}

{% trans "No replication slots." %}

{% endif %}
{% trans "โš  An unused slot keeps WAL forever โ€” drop it when done." %}