Skip to content

Commit ac58b5c

Browse files
committed
2 parents e377fcb + fcbe771 commit ac58b5c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ If `BACKUP_LOCATION` = `S3` then the following options are used.
199199
| Parameter | Description | Default |
200200
| --------------------- | ----------------------------------------------------------------------------------------- | ------- |
201201
| `S3_BUCKET` | S3 Bucket name e.g. `mybucket` | |
202-
| `S3_KEY_ID` | S3 Key ID | |
203-
| `S3_KEY_SECRET` | S3 Key Secret | |
202+
| `S3_KEY_ID` | S3 Key ID (Optional) | |
203+
| `S3_KEY_SECRET` | S3 Key Secret (Optional) | |
204204
| `S3_PATH` | S3 Pathname to save to (must NOT end in a trailing slash e.g. '`backup`') | |
205205
| `S3_REGION` | Define region in which bucket is defined. Example: `ap-northeast-2` | |
206206
| `S3_HOST` | Hostname (and port) of S3-compatible service, e.g. `minio:8080`. Defaults to AWS. | |
@@ -210,6 +210,8 @@ If `BACKUP_LOCATION` = `S3` then the following options are used.
210210
| _*OR*_ | | |
211211
| `S3_CERT_SKIP_VERIFY` | Skip verifying self signed certificates when connecting | `TRUE` |
212212

213+
- When `S3_KEY_ID` and/or `S3_KEY_SECRET` is not set, will try to use IAM role assigned (if any) for uploading the backup files to S3 bucket.
214+
213215
#### Upload to a Azure storage account by `blobxfer`
214216

215217
Support to upload backup files with [blobxfer](https://github.com/Azure/blobxfer) to the Azure fileshare storage.

install/assets/functions/10-db-backup

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ bootstrap_variables() {
100100
;;
101101
esac
102102

103-
if [ "${BACKUP_LOCATION,,}" = "s3" ] || [ "${BACKUP_LOCATION,,}" = "minio" ] ; then
103+
if [ "${BACKUP_LOCATION,,}" = "s3" ] || [ "${BACKUP_LOCATION,,}" = "minio" ] && [ -n "${S3_KEY_ID}" ] && [ -n "${S3_KEY_SECRET}" ]; then
104104
file_env 'S3_KEY_ID'
105105
file_env 'S3_KEY_SECRET'
106106
fi
@@ -652,8 +652,12 @@ move_dbbackup() {
652652
;;
653653
"s3" | "minio" )
654654
print_debug "Moving backup to S3 Bucket"
655-
export AWS_ACCESS_KEY_ID=${S3_KEY_ID}
656-
export AWS_SECRET_ACCESS_KEY=${S3_KEY_SECRET}
655+
if [ -n "${S3_KEY_ID}" ] && [ -n "${S3_KEY_SECRET}" ]; then
656+
export AWS_ACCESS_KEY_ID=${S3_KEY_ID}
657+
export AWS_SECRET_ACCESS_KEY=${S3_KEY_SECRET}
658+
else
659+
print_debug "Variable S3_KEY_ID or S3_KEY_SECRET is not set. Please ensure sufficiant IAM role is assigned."
660+
fi
657661
export AWS_DEFAULT_REGION=${S3_REGION}
658662
if [ -f "${S3_CERT_CA_FILE}" ] ; then
659663
print_debug "Using Custom CA for S3 Backups"
@@ -809,7 +813,7 @@ sanity_test() {
809813
;;
810814
esac
811815

812-
if [ "${BACKUP_LOCATION,,}" = "s3" ] || [ "${BACKUP_LOCATION,,}" = "minio" ] ; then
816+
if [ "${BACKUP_LOCATION,,}" = "s3" ] || [ "${BACKUP_LOCATION,,}" = "minio" ] && [ -n "${S3_KEY_ID}" ] && [ -n "${S3_KEY_SECRET}" ]; then
813817
sanity_var S3_BUCKET "S3 Bucket"
814818
sanity_var S3_PATH "S3 Path"
815819
sanity_var S3_REGION "S3 Region"
@@ -827,6 +831,7 @@ setup_mode() {
827831
if var_true "${MANUAL_RUN_FOREVER}" ; then
828832
mkdir -p /etc/services.d/99-run_forever
829833
cat <<EOF > /etc/services.d/99-run_forever/run
834+
830835
#!/bin/bash
831836
while true
832837
do

0 commit comments

Comments
 (0)