From dc99f875a7a00b3750481e82e2c04891d30f32e2 Mon Sep 17 00:00:00 2001 From: Rohit Hazra Date: Wed, 11 Mar 2020 13:35:10 +0530 Subject: [PATCH 1/5] allow backup name to be changed --- README.md | 3 ++- backup.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ee573a1..e005d69 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ docker run -d --name mongodump \ lgatica/mongodump-s3 ``` -## IAM Policity +## IAM Policiy You need to add a user with the following policies. Be sure to change `your_bucket` by the correct. @@ -103,6 +103,7 @@ You need to add a user with the following policies. Be sure to change `your_buck - `S3_PATH` - Default value is `mongodb`. Example `s3://your_bucket/mongodb` - `MONGO_COMPLETE` - Default not set. If set doing backup full mongodb - `MAX_BACKUPS` - Default not set. If set doing it keeps the last n backups in /backup +- `BACKUP_NAME` - Default is `$(date -u +%Y-%m-%d_%H-%M-%S)_UTC.gz`. If set this is the name of the backup file. Useful when using s3 versioning. (Remember to place .gz extension on your filename) ## License diff --git a/backup.sh b/backup.sh index 5ddc97b..f883809 100755 --- a/backup.sh +++ b/backup.sh @@ -1,7 +1,8 @@ #!/usr/bin/env sh OPTIONS=`python /usr/local/bin/mongouri` -BACKUP_NAME="$(date -u +%Y-%m-%d_%H-%M-%S)_UTC.gz" +DEFAULT_BACKUP_NAME="$(date -u +%Y-%m-%d_%H-%M-%S)_UTC.gz" +BACKUP_NAME=${BACKUP_NAME:-$DEFAULT_BACKUP_NAME} # Run backup mongodump ${OPTIONS} -o /backup/dump From eb7c7a56e1bd57092cf002d0a083332eb1c2fdf6 Mon Sep 17 00:00:00 2001 From: Rohit Hazra Date: Wed, 11 Mar 2020 13:38:18 +0530 Subject: [PATCH 2/5] fix spellings --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e005d69..bf381b8 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ docker run -d --name mongodump \ lgatica/mongodump-s3 ``` -### Inmediatic backup +### Immediate backup ```bash docker run -d --name mongodump \ @@ -65,9 +65,9 @@ docker run -d --name mongodump \ lgatica/mongodump-s3 ``` -## IAM Policiy +## IAM Policy -You need to add a user with the following policies. Be sure to change `your_bucket` by the correct. +You need to add a user with the following policies. Be sure to change `your_bucket` by the correct name. ```xml { From b211965595d10c37594dccc271511c79c555bab3 Mon Sep 17 00:00:00 2001 From: Rohit Hazra Date: Wed, 11 Mar 2020 13:38:53 +0530 Subject: [PATCH 3/5] fix spellings --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bf381b8..952c332 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ You need to add a user with the following policies. Be sure to change `your_buck } ``` -## Extra environmnet +## Extra environment - `S3_PATH` - Default value is `mongodb`. Example `s3://your_bucket/mongodb` - `MONGO_COMPLETE` - Default not set. If set doing backup full mongodb From cf03afbbef3dfa12ac161ec01c379c8e4413c57d Mon Sep 17 00:00:00 2001 From: Rohit Hazra Date: Wed, 11 Mar 2020 14:33:25 +0530 Subject: [PATCH 4/5] add extra options --- README.md | 1 + backup.sh | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 952c332..c1cdcfa 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ You need to add a user with the following policies. Be sure to change `your_buck - `MONGO_COMPLETE` - Default not set. If set doing backup full mongodb - `MAX_BACKUPS` - Default not set. If set doing it keeps the last n backups in /backup - `BACKUP_NAME` - Default is `$(date -u +%Y-%m-%d_%H-%M-%S)_UTC.gz`. If set this is the name of the backup file. Useful when using s3 versioning. (Remember to place .gz extension on your filename) +- `EXTRA_OPTIONS` - Default not set. You would probably need `--authenticationDatabase=admin` ## License diff --git a/backup.sh b/backup.sh index f883809..0878302 100755 --- a/backup.sh +++ b/backup.sh @@ -1,6 +1,7 @@ #!/usr/bin/env sh -OPTIONS=`python /usr/local/bin/mongouri` +OPTIONS=`python mongouri.py` +OPTIONS="$OPTIONS $EXTRA_OPTIONS" DEFAULT_BACKUP_NAME="$(date -u +%Y-%m-%d_%H-%M-%S)_UTC.gz" BACKUP_NAME=${BACKUP_NAME:-$DEFAULT_BACKUP_NAME} @@ -22,4 +23,4 @@ if [ -n "${MAX_BACKUPS}" ]; then done else rm -rf /backup/* -fi +fi \ No newline at end of file From 4ee3b29e09ec0581cc5fc802abe6a9b683f8b3cf Mon Sep 17 00:00:00 2001 From: Rohit Hazra Date: Wed, 11 Mar 2020 14:43:14 +0530 Subject: [PATCH 5/5] add things in readme --- README.md | 7 ++++++- backup.sh | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c1cdcfa..e0dad3b 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,12 @@ You need to add a user with the following policies. Be sure to change `your_buck - `MONGO_COMPLETE` - Default not set. If set doing backup full mongodb - `MAX_BACKUPS` - Default not set. If set doing it keeps the last n backups in /backup - `BACKUP_NAME` - Default is `$(date -u +%Y-%m-%d_%H-%M-%S)_UTC.gz`. If set this is the name of the backup file. Useful when using s3 versioning. (Remember to place .gz extension on your filename) -- `EXTRA_OPTIONS` - Default not set. You would probably need `--authenticationDatabase=admin` +- `EXTRA_OPTIONS` - Default not set. + +## Troubleshoot + +1. If you get SASL Authentication failure, add `--authenticationDatabase=admin` to EXTRA_OPTIONS. +2. If you get "Failed: error writing data for collection ... Unrecognized field 'snapshot'", add `--forceTableScan` to EXTRA_OPTIONS. ## License diff --git a/backup.sh b/backup.sh index 0878302..d9c44e3 100755 --- a/backup.sh +++ b/backup.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -OPTIONS=`python mongouri.py` +OPTIONS=`python /usr/local/bin/mongouri` OPTIONS="$OPTIONS $EXTRA_OPTIONS" DEFAULT_BACKUP_NAME="$(date -u +%Y-%m-%d_%H-%M-%S)_UTC.gz" BACKUP_NAME=${BACKUP_NAME:-$DEFAULT_BACKUP_NAME}