From afb6536a47b206f853a5556ea70a3f9a278888ad Mon Sep 17 00:00:00 2001 From: Juanique Voogt Date: Fri, 8 Aug 2025 08:39:07 +0200 Subject: [PATCH] add stanza script --- Dockerfile | 8 +++++++- stanza-create.sh | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 stanza-create.sh diff --git a/Dockerfile b/Dockerfile index 138979a..7781a06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -118,6 +118,11 @@ RUN chmod 777 /var/log/pgbackrest/postgres-stanza-create.log # Copy pgBackRest configuration file COPY ./pgbackrest/pgbackrest.conf /etc/pgbackrest/pgbackrest.conf +# Copy stanza-create script +COPY ./stanza-create.sh /usr/local/bin/stanza-create.sh +RUN chmod +x /usr/local/bin/stanza-create.sh + + # Add a backup script COPY ./pgbackrest/backup-script.sh /usr/local/bin/backup-script.sh RUN chmod +x /usr/local/bin/backup-script.sh @@ -216,7 +221,8 @@ RUN set -eux \ RUN echo 'figlet -t "Kartoza Docker PostGIS"' >> ~/.bashrc -ENTRYPOINT ["/bin/bash", "-c", "/scripts/docker-entrypoint.sh && cron -f"] +ENTRYPOINT ["/bin/bash", "-c", "/scripts/docker-entrypoint.sh && /usr/local/bin/stanza-create.sh && cron -f"] + ############################################################################## diff --git a/stanza-create.sh b/stanza-create.sh new file mode 100755 index 0000000..f8bf8db --- /dev/null +++ b/stanza-create.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Wait for PostgreSQL to be ready +until pg_isready -h localhost -U "$POSTGRES_USER" -d "$POSTGRES_DB"; do + echo "Waiting for PostgreSQL..." + sleep 2 +done + +# Create the stanza if it doesn't exist +if ! pgbackrest info --stanza=postgres > /dev/null 2>&1; then + echo "Creating pgBackRest stanza..." + pgbackrest --stanza=postgres stanza-create +else + echo "Stanza already exists." +fi