Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile-4.4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mongo:4.4.1
FROM mongo:4.4.5
MAINTAINER Ilya Stepanov <dev@ilyastepanov.com>

RUN apt-get update && \
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Docker image with `mongodump`, `cron` and AWS CLI to upload backups to AWS S3.
| `TARGET_S3_FOLDER` | Folder to upload backups. Leave it empty to disable upload to S3. | `''` |
| `AWS_ACCESS_KEY_ID` | AWS Access Key ID. Leave empty if you want to use AWS IAM Role instead. | `''` |
| `AWS_SECRET_ACCESS_KEY` | AWS Access Key ID. Leave empty if you want to use AWS IAM Role instead. | `''` |
| `TZ` | Timezone | `''` |
| `DATE` | Override Date in generated Filename. Leave empty to use $(date +%Y%m%d_%H%M%S) | `''` |

### Examples

Expand Down
6 changes: 4 additions & 2 deletions backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ set -eo pipefail

echo "Job started: $(date)"

DATE=$(date +%Y%m%d_%H%M%S)
if [[ -z "$DATE" ]]; then
DATE=$(date +%Y%m%d_%H%M%S)
fi

if [[ -z "$TARGET_FOLDER" ]]; then
# dump directly to AWS S3
Expand All @@ -14,7 +16,7 @@ if [[ -z "$TARGET_FOLDER" ]]; then
exit 1
fi

mongodump --uri "$MONGO_URI" --gzip --archive | aws s3 cp - "${TARGET_S3_FOLDER%/}/backup-$DATE.tar.gz"
mongodump --uri "$MONGO_URI" --gzip --archive | /usr/local/bin/aws s3 cp - "${TARGET_S3_FOLDER%/}/backup-$DATE.tar.gz"
echo "Mongo dump uploaded to $TARGET_S3_FOLDER"
else
# save dump locally (and optionally to AWS S3)
Expand Down