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
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ docker run -d --name mongodump \
lgatica/mongodump-s3
```

### Inmediatic backup
### Immediate backup

```bash
docker run -d --name mongodump \
Expand All @@ -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
{
Expand Down Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions backup.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,4 +23,4 @@ if [ -n "${MAX_BACKUPS}" ]; then
done
else
rm -rf /backup/*
fi
fi