tenseleyflow/shithub / d034668

Browse files

ansible(pg): conf.d drop-in to enable WAL archiving

Authored by espadonne
SHA
d03466872f10135c72337c751eb7f7b9c00507f5
Parents
e43d4a2
Tree
18c038a

1 changed file

StatusFile+-
A deploy/ansible/roles/postgres/templates/99_shithub_archive.conf 28 0
deploy/ansible/roles/postgres/templates/99_shithub_archive.confadded
@@ -0,0 +1,28 @@
1
+# Managed by Ansible — drop-in include for /etc/postgresql/16/main/conf.d/.
2
+# Postgres reads everything in conf.d after the main postgresql.conf
3
+# (the Debian-shipped file enables `include_dir = 'conf.d'`).
4
+#
5
+# We use a drop-in instead of overwriting postgresql.conf because the
6
+# Debian package's default file carries dozens of platform-specific
7
+# settings that touching them risks breaking. Smaller blast radius.
8
+#
9
+# Changing archive_mode requires a full Postgres RESTART (not just
10
+# reload) — the SIGHUP-reload path can't toggle it.
11
+
12
+# WAL archiving — required for PITR. Ships every WAL segment to
13
+# spaces-prod:shithub-wal via /usr/local/bin/shithub-pg-archive.
14
+# Operator must:
15
+#   1. Create the shithub-wal bucket in the primary Spaces region
16
+#      (and shithub-wal-dr in the DR region for sync-cross-region.sh).
17
+#   2. Extend the prod RW Spaces key's grants to include readwrite
18
+#      on both buckets.
19
+#   3. systemctl restart postgresql@16-main
20
+#   4. Verify: SELECT * FROM pg_stat_archiver \\gx — last_archived_wal
21
+#      becomes non-null within ~60s (archive_timeout).
22
+wal_level = replica
23
+archive_mode = on
24
+archive_command = '/usr/local/bin/shithub-pg-archive %p %f'
25
+# Force WAL rotation if no segment fills naturally — bounds RPO at
26
+# 60s on a quiet server. The penalty is one extra ~16 MB segment per
27
+# minute of idle, which Spaces lifecycle handles cheaply.
28
+archive_timeout = 60