migrate db back to postgres:14 and manually add wal-g automated incremental backups

This commit is contained in:
2026-08-12 11:23:08 +01:00
parent 3d13c5a9d9
commit 9ebb4283af
5 changed files with 42 additions and 8 deletions
+7 -8
View File
@@ -60,19 +60,18 @@ services:
ports:
- "${DOCKER_SERVICES_IP_BIND:-127.0.0.1}:6379:6379"
db:
image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-14.11-0
build: ./docker/postgres
restart: "unless-stopped"
environment:
- "POSTGRES_USER=${POSTGRES_USER:-i-form-data-repository}"
- "POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-i-form-data-repository}"
- "POSTGRES_DB=${POSTGRES_DB:-i-form-data-repository}"
- "PGBACKREST_REPO1_TYPE=s3"
- "PGBACKREST_REPO1_S3_BUCKET=${INVENIO_S3_BUCKET_NAME}"
- "PGBACKREST_REPO1_S3_ENDPOINT=${INVENIO_S3_ENDPOINT_URL}"
- "PGBACKREST_REPO1_S3_KEY=${INVENIO_S3_ACCESS_KEY_ID}"
- "PGBACKREST_REPO1_S3_KEY_SECRET=${INVENIO_S3_SECRET_ACCESS_KEY}"
- "PGBACKREST_REPO1_S3_REGION=${INVENIO_S3_REGION_NAME}"
- "PGBACKREST_REPO1_PATH=/backup/meta_db"
- "WALG_S3_PREFIX=s3://${INVENIO_S3_BUCKET_NAME}/walg"
- "AWS_ACCESS_KEY_ID=${INVENIO_S3_ACCESS_KEY_ID}"
- "AWS_SECRET_ACCESS_KEY=${INVENIO_S3_SECRET_ACCESS_KEY}"
- "AWS_ENDPOINT=${INVENIO_S3_ENDPOINT_URL}"
- "AWS_REGION=${INVENIO_S3_REGION_NAME}"
- "AWS_S3_FORCE_PATH_STYLE=true"
ports:
- "${DOCKER_SERVICES_IP_BIND:-127.0.0.1}:5432:5432"
logging:
@@ -0,0 +1,19 @@
FROM postgres:14.13
RUN apt-get update && apt-get install -y curl cron && rm -rf /var/lib/apt/lists/*
RUN curl -L "https://github.com/wal-g/wal-g/releases/download/v3.0.8/wal-g-pg-ubuntu-20.04-amd64.tar.gz" | tar -xz && \
mv wal-g-pg-ubuntu-20.04-amd64 /usr/local/bin/wal-g && \
chmod +x /usr/local/bin/wal-g
COPY setup-walg.sh /docker-entrypoint-initdb.d/
COPY entrypoint-wrapper.sh /usr/local/bin/
COPY walg-cron /etc/cron.d/walg-cron
RUN chmod +x /usr/local/bin/entrypoint-wrapper.sh && \
chmod +x /docker-entrypoint-initdb.d/setup-walg.sh && \
chmod 0644 /etc/cron.d/walg-cron && \
crontab /etc/cron.d/walg-cron
ENTRYPOINT ["entrypoint-wrapper.sh"]
CMD ["postgres"]
@@ -0,0 +1,8 @@
#!/bin/bash
set -e
# Start the cron service in the background
service cron start
# Pass execution back to the official postgres entrypoint
exec /usr/local/bin/docker-entrypoint.sh "$@"
@@ -0,0 +1,7 @@
#!/bin/bash
set -e
# Configure postgres to archive WAL logs via wal-g
echo "archive_mode = on" >> "$PGDATA/postgresql.conf"
echo "archive_command = 'wal-g wal-push %p'" >> "$PGDATA/postgresql.conf"
echo "archive_timeout = 60" >> "$PGDATA/postgresql.conf"
@@ -0,0 +1 @@
0 2 * * * postgres /usr/local/bin/wal-g backup-push /var/lib/postgresql/data > /proc/1/fd/1 2>&1