Skip to main content

Backup MongoDB databases using AWS Lambda functions

Project description

mongo-lambda-backup

Build Status

Backup MongoDB databases using AWS Lambda functions

The code in this repo allows running the backup of a MongoDB database to S3 on AWS Lambda by emulating a mongodump using pymongo and boto3. By default the function will create a JSON file for every collection in the database and save them in a /backup folder.

Install from pip

pip install mongo_lambda_backup

Configuration

All configuration values are passed using environment variables.

The following values are required:

  • MONGO_URI: The URI including authentication credentials of the MongoDB host to be backed up.
  • BUCKET_NAME: The name of the S3 bucket to store the backup files in.

The following values are optional:

  • MONGO_URI_IS_ENCRYPTED: In case this environment variable is set, the handler assumes the URI (which potentially contains credentials) needs to be encrypted using the KMS key associated with the Lambda.
  • MONGO_DATABASE: The name of the database to back up. In case this is not set, it will be read from the path of MONGO_URI.
  • BUCKET_FOLDER: The folder in the bucket to store the JSON files in. Defaults to backups.
  • COLLECTION_BLACKLIST: A comma-separated collection of collection names to skip when performing the back up (e.g. for skipping indices).

License

MIT © Frederik Ring

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mongo_lambda_backup-0.2.0.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

mongo_lambda_backup-0.2.0-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page