Skip to content

Commit 8f0c5f7

Browse files
committed
Add AWS s3 v4 auth mechanism fix
1 parent 90c8618 commit 8f0c5f7

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
This image runs mongodump to backup data using cronjob to an s3 bucket
44

5+
## Forked from [halvves/mongodb-backup-s3](https://github.com/halvves/mongodb-backup-s3)
6+
7+
Added support for AWS S3 v4 authorization mechanism for those who are experiencing error:
8+
9+
```
10+
A client error (InvalidRequest) occurred when calling the PutObject operation: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
11+
```
12+
13+
Play well with this docker [nginx-letsencrypt-mongo-portainer] setup
14+
515
## Usage:
616

717
```
@@ -13,10 +23,10 @@ docker run -d \
1323
--env MONGODB_PORT=27017 \
1424
--env MONGODB_USER=admin \
1525
--env MONGODB_PASS=password \
16-
halvves/mongodb-backup-s3
26+
deenoize/mongodb-backup-s3
1727
```
1828

19-
If you link `halvves/mongodb-backup-s3` to a mongodb container with an alias named mongodb, this image will try to auto load the `host`, `port`, `user`, `pass` if possible. Like this:
29+
If you link `deenoize/mongodb-backup-s3` to a mongodb container with an alias named mongodb, this image will try to auto load the `host`, `port`, `user`, `pass` if possible. Like this:
2030

2131
```
2232
docker run -d \
@@ -26,15 +36,15 @@ docker run -d \
2636
--env BACKUP_FOLDER=a/sub/folder/path/ \
2737
--env INIT_BACKUP=true \
2838
--link my_mongo_db:mongodb \
29-
halvves/mongodb-backup-s3
39+
deenoize/mongodb-backup-s3
3040
```
3141

3242
Add to a docker-compose.yml to enhance your robotic army:
3343

3444
For automated backups
3545
```
3646
mongodbbackup:
37-
image: 'halvves/mongodb-backup-s3:latest'
47+
image: 'deenoize/mongodb-backup-s3:latest'
3848
links:
3949
- mongodb
4050
environment:
@@ -48,7 +58,7 @@ mongodbbackup:
4858
Or use `INIT_RESTORE` with `DISABLE_CRON` for seeding/restoring/starting a db (great for a fresh instance or a dev machine)
4959
```
5060
mongodbbackup:
51-
image: 'halvves/mongodb-backup-s3:latest'
61+
image: 'deenoize/mongodb-backup-s3:latest'
5262
links:
5363
- mongodb
5464
environment:
@@ -114,4 +124,4 @@ docker exec mongodb-backup-s3 /restore.sh
114124

115125
## Acknowledgements
116126

117-
* forked from [futurist](https://github.com/futurist)'s fork of [tutumcloud/mongodb-backup](https://github.com/tutumcloud/mongodb-backup)
127+
* forked from [halvves/mongodb-backup-s3](https://github.com/halvves/mongodb-backup-s3) fork of [futurist](https://github.com/futurist)'s fork of [tutumcloud/mongodb-backup](https://github.com/tutumcloud/mongodb-backup)

run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ TIMESTAMP=\`/bin/date +"%Y%m%dT%H%M%S"\`
2626
BACKUP_NAME=\${TIMESTAMP}.dump.gz
2727
S3BACKUP=${S3PATH}\${BACKUP_NAME}
2828
S3LATEST=${S3PATH}latest.dump.gz
29+
aws configure set default.s3.signature_version s3v4
2930
echo "=> Backup started"
3031
if mongodump --host ${MONGODB_HOST} --port ${MONGODB_PORT} ${USER_STR}${PASS_STR}${DB_STR} --archive=\${BACKUP_NAME} --gzip ${EXTRA_OPTS} && aws s3 cp \${BACKUP_NAME} \${S3BACKUP} && aws s3 cp \${S3BACKUP} \${S3LATEST} && rm \${BACKUP_NAME} ;then
3132
echo " > Backup succeeded"
@@ -47,6 +48,7 @@ else
4748
RESTORE_ME=latest.dump.gz
4849
fi
4950
S3RESTORE=${S3PATH}\${RESTORE_ME}
51+
aws configure set default.s3.signature_version s3v4
5052
echo "=> Restore database from \${RESTORE_ME}"
5153
if aws s3 cp \${S3RESTORE} \${RESTORE_ME} && mongorestore --host ${MONGODB_HOST} --port ${MONGODB_PORT} ${USER_STR}${PASS_STR}${DB_STR} --drop --archive=\${RESTORE_ME} --gzip && rm \${RESTORE_ME}; then
5254
echo " Restore succeeded"

0 commit comments

Comments
 (0)