Creates a snapshot of each EBS volume attached to the list of instances provided in aws_snapshotter_settings (or all instances if an empty array is provided).
This project has been retired and is no longer being supported by City Index Ltd.
-
if you should choose to fork it outside of City Index, please let us know so we can link to your project
Creates a snapshot of each EBS volume attached to the list of instances provided in aws_snapshotter_settings (or all instances if an empty array is provided).
Each instance is stopped, to ensure that the snapshot will contain consistent data.
Snapshot history is deleted based on the “snapshots_to_keep” value in the settings file. This specifies how many backup snapshots should be kept for each EBS volume on each instance specified.
An aws_snapshotter_settings.rb.example file is provided, to configure the aws_snapshotter just…
$ cp aws_snapshotter_settings.rb.example aws_snapshotter_settings.rb
Then change the values to include your AWS credentials, and the list of instances you want to create snapshots for. Easy!
The AWS Snapshotter currently depends upon a build of the right_http_connection and right_aws gems which is not available in gem source. You must install them manually, specifying a source, like so.
$ wget http://rgeyer.s3.amazonaws.com/gems/right_http_connection-1.3.0.gem $ wget http://rgeyer.s3.amazonaws.com/gems/right_aws-2.1.0.gem $ gem install right_http_connection-1.3.0.gem $ gem install right_aws-2.1.0.gem
There is an iampolicy.json document included in the repository. This is intended to be used with Amazon’s Identity and Access Management (IAM)
To apply this policy follow the “Get Tools” directions here, then run the following commands. This assumes that all of the iam binaries are accessible in your PATH environment variable, and that you’re PWD is the directory which contains aws_snapshotter
$ iam-groupcreate -g AWSSnapshotter -v $ iam-groupuploadpolicy -g AWSSnapshotter -f ./iam_policy.json -p SnapshotterActions $ iam-usercreate -g AWSSnapshotter -k -u aws_snapshotter -v
The first and second line of the response of iam-usercreate are the AWS Access Key ID and AWS Secret Access Key which are needed in your settings file.
Once you’ve created the IAM user and configured your aws_snapshotter_settings file, you can run the AWS Snapshotter with this simple command.
$ ruby create_snaps.rb
The AWS Snapshotter is designed to take periodic snapshots of running EC2 instances. The following assumptions are made about the instances defined in the Settings::instances directive of the settings file (or all instances for your account, if Settings::instances is left empty).
-
The instances are EBS backed, and can be stopped/started
-
The instances are in the “running” state when the AWS Snapshotter is run
In order to ensure data integrity of the snapshots which are created, the running instances are first stopped so that I/O to the EBS volumes is halted. The snapshot request is issued only after AWS Snapshotter verifies that the instance is stopped, and the instances are immediately restarted after the snapshot request is made.
If an instance is stopped when the AWS Snapshotter is executed, no snapshot will be made for the EBS volumes attached to it, even if the instance is listed in the Settings::instances directive.
-
More error handling
-
It’s okay if stopping and snapshotting instances fail, it’s not okay if the instances are never restarted.
-
-
Enhancements
-
Maybe it’s okay to take snapshots for instances that are listed and are already in the stopped state?
-
Copyright 2011 City Index Ltd.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.