Code Monkey home page Code Monkey logo

aws-lambda-mongodump's Introduction

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 if needed) of the MongoDB host to be backed up. In case this contains credentials you can encrypt this value using AWS KMS and set MONGO_URI_IS_ENCRYPTED to tell the Lambda it needs to decrypt the given value.
  • 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 or vendor specific databases).
  • IN_MEMORY: If set, the collection to be dumped to S3 will be buffered solely in the Lambda's memory before writing (instead of being temporarily saved to disk). This might affect both backup speed as well as Lambda Limits in certain scenarios.

License

MIT © Frederik Ring

aws-lambda-mongodump's People

Watchers

ProDev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.