dynamodb-backup-restore
This tool supports following functionality:
- Full backup AWS DynamoDb table to Amazon S3 bucket within or between regions.
- Incremental backup AWS DynamoDb table to Amazon S3 bucket within or between regions.
- AWS Lambda based incremental backup AWS DynamoDb table to Amazon S3 bucket within or between regions.
- Restore AWS DynamoDb table from Amazon S3 bucket within or between regions.
- Deploy and configure Amazon S3 backup bucket.
- Deploy, configure AWS Lambda and add event source.
Built on NodeJS classes and ECMAScript 2015 (ES6).
It can be used independently and as a dependency in your code.
Usage samples
Full backup
$ gulp backup-full --s3bucket <bucket> --s3prefix <prefix> --s3region <region> --dbtable <table> --dbregion <region>
Options:
--s3bucket (required) Amazon S3 backup bucket name
--s3prefix (optional) subfolder for backup(recomend use AWS DynamoDb table name)
--s3region (required) AWS Region for Amazon S3 backup bucket
--dbtable (required) AWS DynamoDb table name
--dbregion (required) AWS Region for AWS DynamoDb table
const Backup = require('dynamodb-backup-restore').Backup;
let config = {
S3Bucket: 'STRING_VALUE',
S3Prefix: 'STRING_VALUE',
S3Region: 'STRING_VALUE',
DbTable: 'STRING_VALUE',
DbRegion: 'STRING_VALUE'
};
let backup = new Backup(config);
backup.full();
Incremental backup
$ gulp backup-incremental --s3bucket <bucket> --s3prefix <prefix> --s3region <region> --dbtable <table> --dbregion <region>
Options:
--s3bucket (required) Amazon S3 backup bucket name
--s3prefix (optional) subfolder for backup(recomend use AWS DynamoDb table name)
--s3region (required) AWS Region for Amazon S3 backup bucket
--dbtable (required) AWS DynamoDb table name
--dbregion (required) AWS Region for AWS DynamoDb table
const Backup = require('dynamodb-backup-restore').Backup;
let config = {
S3Bucket: 'STRING_VALUE',
S3Prefix: 'STRING_VALUE',
S3Region: 'STRING_VALUE',
DbTable: 'STRING_VALUE',
DbRegion: 'STRING_VALUE'
};
let backup = new Backup(config);
backup.incremental();
AWS Lambda based incremental backup
const Backup = require('dynamodb-backup-restore').Backup;
module.exports.handler = (event, context, callback) => {
if (!event.Records) {
callback('There are no items to process.');
}
else {
let config = {
S3Bucket: 'STRING_VALUE',
S3Region: 'STRING_VALUE',
S3Prefix: 'STRING_VALUE'
};
let backup = new Backup(config);
backup.fromDbStream(event.Records).then(() => {
callback();
}).catch(err => {
callback(err);
});
}
}
Restore
$ gulp restore --s3bucket <bucket> --s3prefix <prefix> --s3region <region> --dbtable <table> --dbregion <region>
Options:
--s3bucket (required) Amazon S3 backup bucket name
--s3prefix (optional) subfolder for backup(recomend use AWS DynamoDb table name)
--s3region (required) AWS Region for Amazon S3 backup bucket
--dbtable (required) AWS DynamoDb table name
--dbregion (required) AWS Region for AWS DynamoDb table
const Restore = require('dynamodb-backup-restore').Restore;
let config = {
S3Bucket: 'STRING_VALUE',
S3Prefix: 'STRING_VALUE',
S3Region: 'STRING_VALUE',
DbTable: 'STRING_VALUE',
DbRegion: 'STRING_VALUE',
RestoreTime:'STRING_VALUE'
};
Restore(config);
Deploy S3 Backup Bucket
$ gulp deploy-s3-bucket --s3bucket <bucket> --s3region <region>
Options:
--s3bucket (required) Amazon S3 backup bucket name
--s3region (required) AWS Region for Amazon S3 backup bucket
const Deploy = require('dynamodb-backup-restore').Deploy;
let config = {
S3Bucket: 'STRING_VALUE',
S3Region: 'STRING_VALUE'
};
let deploy = new Deploy(config);
deploy.backupBucket();
Deploy AWS Lambda Function
$ gulp deploy-lambda --s3bucket <bucket> --s3prefix <prefix> --s3region <region> --dbregion <region> --lName <lambdaName> --lRegion <region> --lAlias <lambdaAlias> --lRoleName <lambdaRole>
Options:
--s3bucket (required) Amazon S3 backup bucket name
--s3prefix (optional) subfolder for backup(recomend use AWS DynamoDb table name)
--s3region (required) AWS Region for Amazon S3 backup bucket
--dbregion (required) AWS Region for AWS DynamoDb table
--lName (required) AWS Lambda Function Name
--lRegion (required) AWS Region for AWS Lambda Funtion
--lAlias (required) AWS Lambda Function Alias
--lRoleName (required) AWS Lambda Function Execution Role
const Deploy = require('dynamodb-backup-restore').Deploy;
let config = {
S3Bucket: 'STRING_VALUE',
S3Prefix: 'STRING_VALUE',
S3Region: 'STRING_VALUE',
DbRegion: 'STRING_VALUE',
LambdaName: 'STRING_VALUE',
LambdaRegion: 'STRING_VALUE',
LambdaAlias: 'STRING_VALUE',
LambdaRoleName: 'STRING_VALUE'
};
let deploy = new Deploy(config);
deploy.lambda();
Deploy AWS Lambda Event
$ gulp deploy-lambda-event --dbtable <table> --dbregion <region> --lName <lambdaName> --lRegion <region> --lAlias <lambdaAlias>
Options:
--dbtable (required) AWS DynamoDb table name
--dbregion (required) AWS Region for AWS DynamoDb table
--lName (required) AWS Lambda Function Name
--lRegion (required) AWS Region for AWS Lambda Funtion
--lAlias (required) AWS Lambda Function Alias
const Deploy = require('dynamodb-backup-restore').Deploy;
let config = {
DbTable: 'STRING_VALUE',
DbRegion: 'STRING_VALUE',
LambdaName: 'STRING_VALUE',
LambdaRegion: 'STRING_VALUE',
LambdaAlias: 'STRING_VALUE'
};
let deploy = new Deploy(config);
deploy.lambdaEvent();