rds-rotate-db-snapshots

<img src=“https://badge.fury.io/rb/rds-rotate-db-snapshots.svg” alt=“Gem Version” />

Provides a simple way to rotate db snapshots in Amazon Relational Database Service (RDS).

Tested on Rubies

Usage

Gem installation:

gem install rds-rotate-db-snapshots

Usage:

rds-rotate-db-snapshots [options] <db_indentifier>

Add this script to CRON (let’s say it will run this script every X hours) and it will do the job well

#/usr/bin/bash
AWS_ACCESS_KEY='xxxxxxxxxxxxxxxxxxxx'
AWS_SECRET_ACCESS_KEY='yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
AWS_SESSION_TOKEN='session_token_goes_here'
AWS_REGION='eu-west-1'
DESCRIPTION_PREFIX='automatic-backup-'
RDS_ROTATOR=/here/is/the/path/to/rds-rotate-db-snapshots
DB_NAME='db_name_here'

$RDS_ROTATOR --aws-region $AWS_REGION --aws-access-key $AWS_ACCESS_KEY --aws-secret-access-key $AWS_SECRET_ACCESS_KEY --aws-session-token $AWS_SESSION_TOKEN --pattern $DESCRIPTION_PREFIX --keep-hourly 24 --keep-daily 7 --keep-weekly 4 --keep-monthly 1 --keep-yearly 0 --create-snapshot $DESCRIPTION_PREFIX$DB_NAME $DB_NAME

Options

Tips

If you are not sure what happen - add option --dry-run.

In that case the script will not destroy/create anything in RDS, it will just show the messages.

Contributing to rds-rotate-db-snapshots

Copyright © 2014 Siarhei Kavaliou. See LICENSE.txt for further details.