Skip to content

Commit 7935add

Browse files
committed
Fixing wal archiving permission issues
1 parent 1fd8ba6 commit 7935add

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

deploy/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: "3.9"
33
services:
44
db:
55
image: postgres:18
6+
entrypoint: ["/usr/local/bin/custom-entrypoint.sh"]
67
environment:
78
POSTGRES_USER: ${POSTGRES_USER:-postgres}
89
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
@@ -13,6 +14,7 @@ services:
1314
- pgwal:/var/lib/postgresql/wal-archive
1415
- pgbackups:/backups
1516
- ./postgres/postgresql.conf:/etc/postgresql/postgresql.conf:ro # copy from postgresql.conf.example
17+
- ./postgres/entrypoint.sh:/usr/local/bin/custom-entrypoint.sh:ro
1618
command:
1719
[
1820
"postgres",

deploy/postgres/entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Ensure WAL archive directory exists and is owned by postgres so archive_command can write.
5+
mkdir -p /var/lib/postgresql/wal-archive
6+
chown -R postgres:postgres /var/lib/postgresql/wal-archive
7+
8+
exec /usr/local/bin/docker-entrypoint.sh "$@"
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
listen_addresses = '*'
2+
3+
# Memory and planner
14
shared_buffers = 4GB
25
effective_cache_size = 12GB
36
work_mem = 32MB
47
maintenance_work_mem = 1GB
58

9+
# WAL and archiving
610
wal_level = replica
711
wal_compression = on
812
archive_mode = on
913
archive_timeout = 60s
10-
archive_command = 'test ! -f /var/lib/postgresql/wal-archive/%f && cp %p /var/lib/postgresql/wal-archive/%f' # keep && unescaped so the shell runs both commands
14+
archive_command = 'test ! -f /var/lib/postgresql/wal-archive/%f && cp %p /var/lib/postgresql/wal-archive/%f'
1115
max_wal_size = 8GB
1216
min_wal_size = 2GB

0 commit comments

Comments
 (0)