diff --git a/README.md b/README.md index ee573a1..e0dad3b 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 Policity +## 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 { @@ -98,11 +98,18 @@ 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 - `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. + +## 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 5ddc97b..d9c44e3 100755 --- a/backup.sh +++ b/backup.sh @@ -1,7 +1,9 @@ #!/usr/bin/env sh OPTIONS=`python /usr/local/bin/mongouri` -BACKUP_NAME="$(date -u +%Y-%m-%d_%H-%M-%S)_UTC.gz" +OPTIONS="$OPTIONS $EXTRA_OPTIONS" +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 @@ -21,4 +23,4 @@ if [ -n "${MAX_BACKUPS}" ]; then done else rm -rf /backup/* -fi +fi \ No newline at end of file