Sign inSign up

gtuk/mongo-dumper

By gtuk

•Updated almost 5 years ago

Easily dump, compress and optionally encrypt your mongodb database/cluster

Image
0

1.6K

gtuk/mongo-dumper repository overview

⁠mongo-dumper

mongo-dumper is a simple cli script to easily dump, compress, encrypt and optionally upload your mongodb database/cluster. The tool is using the --archive and optional the --gzip option from mongodump to create a backup. Keep this in mind if you restore your backup with mongorestore.


⁠Requirements

In order to run the script you need to have gnupg, the minio client (mc) and mongodump installed (version should match the mongodb server).

⁠Make script executable
chmod +x mongo-dumper.sh
⁠Backup with encryption enabled
./mongo-dumper.sh --host localhost --db app --password password --user root --port 27017 --backup-password supersecret --location ./
⁠Backup with encryption disabled
./mongo-dumper.sh --host localhost --db app --password password --user root --port 27017 location ./ --encryption false

⁠Extract backup with encryption enabled
gpg -o backup_file.gz -d backup_file.gpg
⁠Parameters
ParameterDescriptionDefault
hostMongodb host(required)
userMongodb user(required)
passwordMongodb password(required)
dbMongodb db(required if cluster-wide is false)
portMongodb port27017
authenticationDatabaseAuthentication db for the user credentialsmongodump assumes the admin database hold the user credentials authenticationDatabase. If cluster-wide is false mongodump assumes that the db specified holds the user credentials
locationLocation for the backup$HOME
backup-passwordPassword for encryption(required if encryption is true)
encryptionEnable/disable encryptiontrue
cluster-wideBackup whole mongodb clusterfalse
uploadIf true it will upload the backup to a s3 compatible storagefalse
endpoints3 compatible endpoint(required if upload is true)
buckets3 bucket for uploading (needs to end with a slash)(required if upload is true)
access-keys3 compatible storage access-key(required if upload is true)
access-secrets3 compatible storage secret-key(required if upload is true)
api-versionapi-signature (minio client)S3v4
minio-clientcustom location of the minio client (e.g ./mc)mc
⁠Build docker image
# Example to build for mongodb 5.0
docker build --no-cache --build-arg MONGODB_VERSION=5.0 -t mongo-dumper:mongo-5.0 .
⁠Prebuild docker images

https://hub.docker.com/r/gtuk/mongo-dumper⁠

docker run gtuk/mongo-dumper:mongo-5.0 --host <HOST> --password <PASSWORD> --user <USER> --port <PORT> --backup-password <SUPER_SECRET_PASSWORD> --location ./ --cluster-wide true --upload true --endpoint <ENDPOINT> --access-key <ACCESS_KEY> --secret-key <SECRET_KEY> --bucket <BUCKET> --minio-client ./mc

Tag summary

Content type

Image

Digest

Size

200.6 MB

Last updated

almost 5 years ago

docker pull gtuk/mongo-dumper:mongo-4.4