diff --git a/Dockerfile b/Dockerfile index 3e40fbc..cf4c596 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM alpine:3 +FROM alpine:edge WORKDIR /root RUN apk update && \ - apk add bash curl pigz postgresql14-client postgresql15-client postgresql16-client rclone + apk add bash curl pigz postgresql15-client postgresql16-client postgresql17-client rclone COPY docker-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-entrypoint.sh diff --git a/README.md b/README.md index 9f821df..afc3c2f 100644 --- a/README.md +++ b/README.md @@ -20,40 +20,46 @@ | POSTGRES_PASSWORD | ✔ | | Postgres server password | | POSTGRES_PORT | | 5432 | Postgres server port | | POSTGRES_USER | | postgres | Postgres server user | -| POSTGRES_VERSION | | 16 | Postgres server version (14, 15 or 16) | +| POSTGRES_VERSION | | 17 | Postgres server version (15, 16 or 17) | | WEBGAZER_HEARTBEAT_URL | | | [WebGazer Heartbeat Monitor](https://www.webgazer.io/services/cron-job-monitoring) URL | ### Running - $ docker run th0th/postgres-s3-backup \ - -e AWS_ACCESS_KEY_ID= \ - -e AWS_REGION= \ - -e AWS_S3_ENDPOINT= \ - -e AWS_S3_STORAGE_CLASS= \ - -e AWS_SECRET_ACCESS_KEY= \ - -e POSTGRES_DB= \ - -e POSTGRES_HOST= \ - -e POSTGRES_PASSWORD= \ - -e POSTGRES_PORT= \ - -e POSTGRES_USER= \ - -e POSTGRES_VERSION= \ - -e WEBGAZER_HEARTBEAT_URL= +```shell +$ docker run \ + -e AWS_ACCESS_KEY_ID= \ + -e AWS_REGION= \ + -e AWS_S3_ENDPOINT= \ + -e AWS_S3_STORAGE_CLASS= \ + -e AWS_SECRET_ACCESS_KEY= \ + -e POSTGRES_DB= \ + -e POSTGRES_HOST= \ + -e POSTGRES_PASSWORD= \ + -e POSTGRES_PORT= \ + -e POSTGRES_USER= \ + -e POSTGRES_VERSION= \ + -e WEBGAZER_HEARTBEAT_URL= \ + th0th/postgres-s3-backup +``` ### Example - $ docker run th0th/postgres-s3-backup \ - -e AWS_ACCESS_KEY_ID=g9XqNnqKmUk6xqwkStkN \ - -e AWS_REGION=eu-west-1 \ - -e AWS_S3_ENDPOINT=my-bucket/postgres-backup \ - -e AWS_S3_STORAGE_CLASS=GLACIER \ - -e AWS_SECRET_ACCESS_KEY=GLBZ8mQf27UL57YHbkLhXWtfJWVwtUBbQup6mFzw \ - -e POSTGRES_DB=database \ - -e POSTGRES_HOST=postgres \ - -e POSTGRES_PASSWORD=postgres_password \ - -e POSTGRES_PORT=5432 \ - -e POSTGRES_USER=postgres_user \ - -e POSTGRES_VERSION=15 \ - -e WEBGAZER_HEARTBEAT_URL=https://heartbeat.webgazer.io/1-8f713c75d659 +```shell +$ docker run \ + -e AWS_ACCESS_KEY_ID=g9XqNnqKmUk6xqwkStkN \ + -e AWS_REGION=eu-west-1 \ + -e AWS_S3_ENDPOINT=my-bucket/postgres-backup \ + -e AWS_S3_STORAGE_CLASS=GLACIER \ + -e AWS_SECRET_ACCESS_KEY=GLBZ8mQf27UL57YHbkLhXWtfJWVwtUBbQup6mFzw \ + -e POSTGRES_DB=database \ + -e POSTGRES_HOST=postgres \ + -e POSTGRES_PASSWORD=postgres_password \ + -e POSTGRES_PORT=5432 \ + -e POSTGRES_USER=postgres_user \ + -e POSTGRES_VERSION=17 \ + -e WEBGAZER_HEARTBEAT_URL=https://heartbeat.webgazer.io/1-8f713c75d659 \ + th0th/postgres-s3-backup +``` ## Shameless plug diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0622113..0a5c803 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -eo pipefail SECONDS=0 @@ -17,10 +16,10 @@ AWS_S3_STORAGE_CLASS="${AWS_S3_STORAGE_CLASS:-STANDARD_IA}" POSTGRES_HOST="${POSTGRES_HOST:-postgres}" POSTGRES_PORT="${POSTGRES_PORT:-5432}" POSTGRES_USER="${POSTGRES_USER:-postgres}" -POSTGRES_VERSION="${POSTGRES_VERSION:-16}" +POSTGRES_VERSION="${POSTGRES_VERSION:-17}" # validate environment variables -POSTGRES_VERSIONS=(14 15 16) +POSTGRES_VERSIONS=(15 16 17) if [[ ! " ${POSTGRES_VERSIONS[*]} " =~ " ${POSTGRES_VERSION} " ]]; then echo "error: POSTGRES_VERSION can be one of these: ${POSTGRES_VERSIONS[*]}" @@ -32,12 +31,12 @@ BACKUP_FILE_NAME=$(date +"${POSTGRES_DB}-%F_%T.gz") echo "Dumping the database..." PGPASSWORD="${POSTGRES_PASSWORD}" "/usr/libexec/postgresql${POSTGRES_VERSION}/pg_dump" \ - --host="${POSTGRES_HOST}" \ - --port="${POSTGRES_PORT}" \ - --username="${POSTGRES_USER}" \ - --dbname="${POSTGRES_DB}" \ - --format=c \ - | pigz --fast > "${BACKUP_FILE_NAME}" + --host="${POSTGRES_HOST}" \ + --port="${POSTGRES_PORT}" \ + --username="${POSTGRES_USER}" \ + --dbname="${POSTGRES_DB}" \ + --format=c \ + | pigz --fast > "${BACKUP_FILE_NAME}" echo "Dumping the database... Done." echo "Uploading to S3..."