add stanza script

16.4
Juanique Voogt 2025-08-08 08:39:07 +02:00
rodzic 3085b9e89f
commit afb6536a47
2 zmienionych plików z 22 dodań i 1 usunięć

Wyświetl plik

@ -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"]
##############################################################################

15
stanza-create.sh 100755
Wyświetl plik

@ -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