Browse Source

Merge pull request #78 from claudyus/master

postgres-backup-s3: Parameters S3_ENDPOINT and S3_S3V4 added.
pull/79/head
Johannes Schickling 8 years ago
committed by GitHub
parent
commit
b26d1130ce
  1. 2
      postgres-backup-s3/Dockerfile
  2. 8
      postgres-backup-s3/backup.sh
  3. 4
      postgres-backup-s3/run.sh

2
postgres-backup-s3/Dockerfile

@ -15,6 +15,8 @@ ENV S3_SECRET_ACCESS_KEY **None**
ENV S3_BUCKET **None**
ENV S3_REGION us-west-1
ENV S3_PATH 'backup'
ENV S3_ENDPOINT **None**
ENV S3_S3V4 no
ENV SCHEDULE **None**
ADD run.sh run.sh

8
postgres-backup-s3/backup.sh

@ -43,6 +43,12 @@ if [ "${POSTGRES_PASSWORD}" = "**None**" ]; then
exit 1
fi
if [ "${S3_ENDPOINT}" == "**None**" ]; then
AWS_ARGS=""
else
AWS_ARGS="--endpoint-url ${S3_ENDPOINT}"
fi
# env vars needed for aws tools
export AWS_ACCESS_KEY_ID=$S3_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$S3_SECRET_ACCESS_KEY
@ -57,6 +63,6 @@ pg_dump $POSTGRES_HOST_OPTS $POSTGRES_DATABASE | gzip > dump.sql.gz
echo "Uploading dump to $S3_BUCKET"
cat dump.sql.gz | aws s3 cp - s3://$S3_BUCKET/$S3_PREFIX/${POSTGRES_DATABASE}_$(date +"%Y-%m-%dT%H:%M:%SZ").sql.gz || exit 2
cat dump.sql.gz | aws $AWS_ARGS s3 cp - s3://$S3_BUCKET/$S3_PREFIX/${POSTGRES_DATABASE}_$(date +"%Y-%m-%dT%H:%M:%SZ").sql.gz || exit 2
echo "SQL backup uploaded successfully"

4
postgres-backup-s3/run.sh

@ -2,6 +2,10 @@
set -e
if [ "${S3_S3V4}" = "yes"]; then
aws configure set default.s3.signature_version s3v4
fi
if [ "${SCHEDULE}" = "**None**" ]; then
sh backup.sh
else

Loading…
Cancel
Save