From 284be0ea4c507fec274fed310448805a20ad0e41 Mon Sep 17 00:00:00 2001 From: Adam Engebretson Date: Wed, 14 Dec 2016 22:17:35 -0600 Subject: [PATCH] Adding support for custom S3 endpoint --- mysql-backup-s3/Dockerfile | 1 + mysql-backup-s3/README.md | 1 + mysql-backup-s3/backup.sh | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mysql-backup-s3/Dockerfile b/mysql-backup-s3/Dockerfile index b7703e3..a4d6006 100644 --- a/mysql-backup-s3/Dockerfile +++ b/mysql-backup-s3/Dockerfile @@ -14,6 +14,7 @@ ENV S3_ACCESS_KEY_ID **None** ENV S3_SECRET_ACCESS_KEY **None** ENV S3_BUCKET **None** ENV S3_REGION us-west-1 +ENV S3_ENDPOINT **None** ENV S3_PREFIX 'backup' ENV MULTI_FILES no ENV SCHEDULE **None** diff --git a/mysql-backup-s3/README.md b/mysql-backup-s3/README.md index 4bb8610..f06eacc 100644 --- a/mysql-backup-s3/README.md +++ b/mysql-backup-s3/README.md @@ -21,6 +21,7 @@ $ docker run -e S3_ACCESS_KEY_ID=key -e S3_SECRET_ACCESS_KEY=secret -e S3_BUCKET - `S3_BUCKET` your AWS S3 bucket path *required* - `S3_PREFIX` path prefix in your bucket (default: 'backup') - `S3_REGION` the AWS S3 bucket region (default: us-west-1) +- `S3_ENDPOINT` the AWS Endpoint URL, for S3 Compliant APIs such as [minio](https://minio.io) (default: none) - `MULTI_FILES` Allow to have one file per database if set `yes` default: no) - `SCHEDULE` backup schedule time, see explainatons below diff --git a/mysql-backup-s3/backup.sh b/mysql-backup-s3/backup.sh index aac9f22..81f0990 100644 --- a/mysql-backup-s3/backup.sh +++ b/mysql-backup-s3/backup.sh @@ -44,9 +44,15 @@ copy_s3 () { SRC_FILE=$1 DEST_FILE=$2 + if[ "${S3_ENDPOINT}" == "**None**" ]; then + AWS_ARGS="" + else + AWS_ARGS="--endpoint-url ${S3_ENDPOINT}" + fi + echo "Uploading ${DEST_FILE} on S3..." - cat $SRC_FILE | aws s3 cp - s3://$S3_BUCKET/$S3_PREFIX/$DEST_FILE + cat $SRC_FILE | aws $AWS_ARGS s3 cp - s3://$S3_BUCKET/$S3_PREFIX/$DEST_FILE if [ $? != 0 ]; then >&2 echo "Error uploading ${DEST_FILE} on S3"