Configure automated DynamoDB "On-Demand" backups and manage backups lifecycle, powered by AWS Lambda
If you want to automate your AWS DynamoDB database backups, this plugin may be what you need.
As we build various services on AWS using the "serverless" design, we need reusable backups services, both scalable and easy to implement. We therefore created this plugin, to make sure that each project can create its own DynamoDB automated backup solution.
This is a plugin which simplifies DynamoDB backups creation automation for all the resources created in
serverless.yml when using the Serverless Framework and AWS Cloud provider.
This plugin officially supports Node.js 6.10 and 8.10.
This plugin officially supports Serverless Framework
Install the plugin using either Yarn or NPM. (we use Yarn)
npm install @unly/serverless-plugin-dynamodb-backups
yarn add @unly/serverless-plugin-dynamodb-backups
The plugin determines your environment during deployment and adds all environment variables to your Lambda function. All you need to do is to load the plugin:
Must be declared before
serverless-webpack, despite what their officially doc says
plugins: - '@unly/serverless-plugin-dynamodb-backups' # Must be first, even before "serverless-webpack", see https://github.com/UnlyEd/serverless-plugin-dynamodb-backups - serverless-webpack # Must be second, see https://github.com/99xt/serverless-dynamodb-local#using-with-serverless-offline-and-serverless-webpack-plugin
Create a file, which will be called when performing a DynamoDB backup (we named it
src/backups.js in our
import dynamodbAutoBackups from 'serverless-plugin-db-backups/lib'; export const handler = dynamodbAutoBackups;
dynamodbAutoBackups object configuration as follows (list of all available options below):
custom: dynamodbAutoBackups: backupRate: rate(40 minutes) # Every 5 minutes, from the time it was deployed source: src/backups.js # Path to the handler function we created in step #2 active: true
|source||String||True||Path to your handler function|
|backupRate||String||True||The schedule on which you want to backup your table. You can use either
|name||String||False||auto||Automatically set, but you could provide your own name for this lambda|
|slackWebhook||String||False||A HTTPS endpoint for an incoming webhook to Slack. If provided, it will send error messages to a Slack channel.|
|backupRemovalEnabled||Boolean||False||false||Enables cleanup of old backups. See the below option "backupRetentionDays" to specify the retention period. By default, backup removal is disabled.|
|backupRetentionDays||Integer||False||Specify the number of days to retain old backups. For example, setting the value to 2 will remove all backups that are older than 2 days. Required if
|active||Boolean||False||true||You can disable this plugin, useful to disable the plugin on a non-production environment, for instance|
Generated by https://www.tablesgenerator.com/markdown_tables
custom: dynamodbAutoBackups: backupRate: rate(40 minutes) # Every 40 minutes, from the time it was deployed source: src/backups.js slackWebhook: https://hooks.slack.com/services/T4XHXX5C6/TT3XXXM0J/XXXXXSbhCXXXX77mFBr0ySAm backupRemovalEnabled: true # Enable backupRetentionDays backupRetentionDays: 15 # If backupRemovalEnabled is not provided, then backupRetentionDays is not used
custom: dynamodbAutoBackups: backupRate: cron(0 2 ? * FRI *) # Every friday at 2:00 am source: src/backups.js slackWebhook: https://hooks.slack.com/services/T4XHXX5C6/TT3XXXM0J/XXXXXSbhCXXXX77mFBr0ySAm backupRemovalEnabled: true # Enable backupRetentionDays backupRetentionDays: 3 # If backupRemovalEnabled is not provided, then backupRetentionDays is not used backupType: USER # Delete all backups created by a user, not the system backups
To test this plugin, you can clone this repository.
examples/serverless-example, and follow the README.
This project is being maintained by:
Thanks to our contributors:
Unly is a socially responsible company, fighting inequality and facilitating access to higher education. Unly is committed to making education more inclusive, through responsible funding for students. We provide technological solutions to help students find the necessary funding for their studies.
We proudly participate in many TechForGood initiatives. To support and learn more about our actions to make education accessible, visit :
Tech tips and tricks from our CTO on our Medium page!
Latest commit b2f54ec on Sep 24, 2017