@trioxis/aws-backup-manager
v0.4.0
Published
Automatically back up EBS volumes using tags
Downloads
4
Readme
aws-backup-manager
Automatically back up EBS volumes using tags
This project is under active development; implementation is incomplete
What does this do?
- Analyse the tags on your EBS volumes and snapshots according to a backup tag API
- Make snapshots as specified by the tags on EBS volumes
- Remove snapshots as specified by the tags on snapshots
Quickstart
Make sure you have your AWS credentials set up. Set the AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
environment variables or see the section 'Setting AWS Credentials' of the AWS docs.
Tag your EBS volumes
To automatically back up an EBS volume hourly, daily, weekly, monthly and yearly, it must have a tag with key backups:config-v0
and value Hourly,Daily,Weekly,Monthly,Yearly
You can remove types of backup from the value as necessary. See the Backup Tag API doc for explanations and more fine grained controls.
Run the script somewhere regularly
To install the script in the current directory, run this line
git clone https://github.com/Trioxis/aws-backup-manager.git . && npm install && npm run build
To do a backup once, run
npm start
This will make and delete EC2 backups as necessary and then exit. This command should be scheduled to run at least once an hour to get the full benefits of the backup manager.
Development
Getting Started
Make sure your AWS credentials are set up then clone the repository to disk
git clone https://github.com/Trioxis/aws-backup-manager.git
then install dependencies
npm install
Testing
To run all tests, run
npm test
This will lint the code then run mocha. Mocha finds test files in test/
and runs them all. It will output a report of all the tests that passed, failed and are pending (tests that are not written yet). Check the mocha docs for info on how to format the tests.
If you only want to lint the code, run
npm run _lint
You can set tests to run automatically with
npm run watch
Your terminal will display updated test status as soon as save your code. (This doesn't do linting, you can use npm run watch-lint
for that).
Code Coverage
Code coverage is checked using isparta by running
npm run cover
This outputs a html report in coverage/
that can be perused in a web browser. It also outputs results to console and in lcov format to send to third party coverage services (see section below)
Continuous Integration
We're using Travis CI for continuous integration. It runs all tests and sends code coverage information to Codecov and CodeClimate. Check .travis.yml
for the tasks that are run in CI.
Note: the CODECLIMATE_REPO_TOKEN
environment variable must be set in Travis CI to successfully send coverage information to CodeClimate
Building
This app is written using ES6 features such as arrow functions, modules and Promises. These features are not yet fully implemented in the Node.js engine that runs the app, so it is necessary to compile the code (using Babel) down to ES5.
To build the code, run
npm run build
The built code appears in the build/
directory. Don't forget the run
part of the command, npm build
does nothing.
Running
To actually run the app, run
npm start
This runs the index.js
file, which uses the built code from the previous step. In the beginning this won't do anything useful since most of the code hasn't been written yet. Running may change later once the code is closer to production stage.
Backup Runner API
The function exported by src/index.js
should run the entire backup process (described in 'What does this do?' section above) using the APIs provided by the modules in src/
. For detail on these APIs, see the API doc.
Backup Tag API
See the Backup Tag API doc.