Skip to content

Commit 2c080a3

Browse files
authored
Merge pull request #27 from sil-org/change-aws-vars
change the AWS access key variables to the AWS CLI standard
2 parents e529ed5 + fae3967 commit 2c080a3

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ Service to backup and/or restore a PostgreSQL database to/from S3
2424

2525
`DB_USER` user that accesses the database (PostgreSQL "role")
2626

27-
`AWS_ACCESS_KEY` used for S3 interactions
27+
`AWS_ACCESS_KEY_ID` used for S3 interactions
2828

29-
`AWS_SECRET_KEY` used for S3 interactions
29+
`AWS_SECRET_ACCESS_KEY` used for S3 interactions
30+
31+
`AWS_ACCESS_KEY` used for S3 interactions (Deprecated)
32+
33+
`AWS_SECRET_KEY` used for S3 interactions (Deprecated)
3034

3135
`S3_BUCKET` e.g., _s3://database-backups_ **NOTE: no trailing slash**
3236

application/backup.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ log() {
1010
# Function to remove sensitive values from sentry Event
1111
filter_sensitive_values() {
1212
local msg="$1"
13-
for var in AWS_ACCESS_KEY AWS_SECRET_KEY B2_APPLICATION_KEY B2_APPLICATION_KEY_ID DB_ROOTPASSWORD DB_USERPASSWORD; do
13+
for var in AWS_ACCESS_KEY AWS_SECRET_KEY AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY B2_APPLICATION_KEY B2_APPLICATION_KEY_ID DB_ROOTPASSWORD DB_USERPASSWORD; do
1414
val="${!var}"
1515
if [ -n "$val" ]; then
1616
msg="${msg//$val/[FILTERED]}"
@@ -63,6 +63,10 @@ start=$(date +%s);
6363
$(PGPASSWORD=${DB_USERPASSWORD} pg_dump --host=${DB_HOST} --username=${DB_USER} --create --clean ${DB_OPTIONS} --dbname=${DB_NAME} > /tmp/${DB_NAME}.sql) || STATUS=$?;
6464
end=$(date +%s);
6565

66+
# maintain backward compatibility with key variables accepted by s3cmd
67+
export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-$AWS_ACCESS_KEY}"
68+
export AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:-$AWS_SECRET_KEY}"
69+
6670
if [ $STATUS -ne 0 ]; then
6771
error_message="${MYNAME}: FATAL: Backup of ${DB_NAME} returned non-zero status ($STATUS) in $(expr ${end} - ${start}) seconds.";
6872
log "ERROR" "${error_message}";

application/restore.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ log() {
99

1010
filter_sensitive_values() {
1111
local msg="$1"
12-
for var in AWS_ACCESS_KEY AWS_SECRET_KEY B2_APPLICATION_KEY B2_APPLICATION_KEY_ID DB_ROOTPASSWORD DB_USERPASSWORD; do
12+
for var in AWS_ACCESS_KEY AWS_SECRET_KEY AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY B2_APPLICATION_KEY B2_APPLICATION_KEY_ID DB_ROOTPASSWORD DB_USERPASSWORD; do
1313
val="${!var}"
1414
if [ -n "$val" ]; then
1515
msg="${msg//$val/[FILTERED]}"
@@ -94,6 +94,10 @@ fi
9494
log "INFO" "${MYNAME}: copying database ${DB_NAME} backup and checksum from ${S3_BUCKET}"
9595
start=$(date +%s)
9696

97+
# maintain backward compatibility with key variables accepted by s3cmd
98+
export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-$AWS_ACCESS_KEY}"
99+
export AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:-$AWS_SECRET_KEY}"
100+
97101
# Download database backup
98102
aws s3 cp "${S3_BUCKET}/${DB_NAME}.sql.gz" "/tmp/${DB_NAME}.sql.gz" || STATUS=$?
99103
if [ $STATUS -ne 0 ]; then

local.env.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
AWS_ACCESS_KEY=
2-
AWS_SECRET_KEY=
1+
AWS_ACCESS_KEY_ID=
2+
AWS_SECRET_ACCESS_KEY=
33
S3_BUCKET=
44

55
# BackBlaze variables

0 commit comments

Comments
 (0)