diff --git a/mysql-backup-s3/Dockerfile b/mysql-backup-s3/Dockerfile index b3c088f..415abaf 100644 --- a/mysql-backup-s3/Dockerfile +++ b/mysql-backup-s3/Dockerfile @@ -17,6 +17,7 @@ ENV S3_REGION us-west-1 ENV S3_ENDPOINT **None** ENV S3_S3V4 no ENV S3_PREFIX 'backup' +ENV S3_FILENAME **None** ENV MULTI_FILES no ENV SCHEDULE **None** diff --git a/mysql-backup-s3/README.md b/mysql-backup-s3/README.md index ac3a29f..bb0d3f7 100644 --- a/mysql-backup-s3/README.md +++ b/mysql-backup-s3/README.md @@ -20,6 +20,7 @@ $ docker run -e S3_ACCESS_KEY_ID=key -e S3_SECRET_ACCESS_KEY=secret -e S3_BUCKET - `S3_SECRET_ACCESS_KEY` your AWS secret key *required* - `S3_BUCKET` your AWS S3 bucket path *required* - `S3_PREFIX` path prefix in your bucket (default: 'backup') +- `S3_FILENAME` a consistent filename to overwrite with your backup. If not set will use a timestamp. - `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) - `S3_S3V4` set to `yes` to enable AWS Signature Version 4, required for [minio](https://minio.io) servers (default: no) diff --git a/mysql-backup-s3/backup.sh b/mysql-backup-s3/backup.sh index ab16c89..eb604e4 100644 --- a/mysql-backup-s3/backup.sh +++ b/mysql-backup-s3/backup.sh @@ -76,7 +76,11 @@ if [ ! -z "$(echo $MULTI_FILES | grep -i -E "(yes|true|1)")" ]; then mysqldump $MYSQL_HOST_OPTS $MYSQLDUMP_OPTIONS --databases $DB | gzip > $DUMP_FILE if [ $? == 0 ]; then - S3_FILE="${DUMP_START_TIME}.${DB}.sql.gz" + if [ "${S3_FILENAME}" == "**None**" ]; then + S3_FILE="${DUMP_START_TIME}.${DB}.sql.gz" + else + S3_FILE="${S3_FILENAME}.${DB}.sql.gz" + fi copy_s3 $DUMP_FILE $S3_FILE else @@ -91,7 +95,11 @@ else mysqldump $MYSQL_HOST_OPTS $MYSQLDUMP_OPTIONS $MYSQLDUMP_DATABASE | gzip > $DUMP_FILE if [ $? == 0 ]; then - S3_FILE="${DUMP_START_TIME}.dump.sql.gz" + if [ "${S3_FILENAME}" == "**None**" ]; then + S3_FILE="${DUMP_START_TIME}.dump.sql.gz" + else + S3_FILE="${S3_FILENAME}.sql.gz" + fi copy_s3 $DUMP_FILE $S3_FILE else