From 38801ea6d3cf1729680cc81ae7a016f575ef261a Mon Sep 17 00:00:00 2001 From: Christopher Usher Date: Sun, 22 Sep 2019 19:57:12 +0100 Subject: [PATCH] Replication working --- postgres/Dockerfile | 2 ++ postgres/standby_setup.sh | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 postgres/standby_setup.sh diff --git a/postgres/Dockerfile b/postgres/Dockerfile index d737976..f7024bf 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -1,3 +1,5 @@ FROM postgres:latest COPY postgres/setup.sh /docker-entrypoint-initdb.d/setup.sh +COPY postgres/standby_setup.sh /standby_setup.sh RUN chmod 0666 /docker-entrypoint-initdb.d/setup.sh +RUN chmod 0700 /standby_setup.sh diff --git a/postgres/standby_setup.sh b/postgres/standby_setup.sh new file mode 100644 index 0000000..045b32c --- /dev/null +++ b/postgres/standby_setup.sh @@ -0,0 +1,23 @@ +#! /bin/bash + + +if [ ! -s "$PGDATA/PG_VERSION" ]; then + + pg_basebackup -d "host=$MASTER_NODE password=$REPLICATION_PASSWORD port=5432 user=$REPLICATION_USER" -D ${PGDATA} -vP + + set -e + + cat > ${PGDATA}/recovery.conf <