Module: SnapEbs::Snapshotter
- Included in:
- SnapEbs
- Defined in:
- lib/snap_ebs/snapshotter.rb
Constant Summary collapse
- AWS_INSTANCE_ID_URL =
'http://169.254.169.254/latest/dynamic/instance-identity/document'
Instance Attribute Summary collapse
-
#compute ⇒ Object
Get the Fog compute object.
Instance Method Summary collapse
-
#take_snapshots ⇒ Object
Takes snapshots of attached volumes (optionally filtering by volumes mounted to the given directories).
Instance Attribute Details
#compute ⇒ Object
Get the Fog compute object. When --mock is given, Fog.mock! is called and information normally auto-detected from AWS is injected with dummy values to circumvent the lazy loaders.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/snap_ebs/snapshotter.rb', line 29 def compute require 'fog/aws' if [:mock] Fog.mock! @region = 'us-east-1' @instance_id = 'i-deadbeef' @instance_name = 'totally-not-the-cia' end @compute ||= Fog::Compute.new({ :aws_access_key_id => access_key, :aws_secret_access_key => secret_key, :region => region, :provider => "AWS" }) end |
Instance Method Details
#take_snapshots ⇒ Object
Takes snapshots of attached volumes (optionally filtering by volumes mounted to the given directories)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/snap_ebs/snapshotter.rb', line 10 def take_snapshots system 'sync' attached_volumes.collect do |vol| dir = device_to_directory device_name vol fs_freeze dir if [:fs_freeze] next unless should_snap vol logger.debug "Snapping #{vol.id}" snapshot = compute.snapshots.new snapshot.volume_id = vol.id snapshot.description = snapshot_name(vol) snapshot.save snapshot fs_unfreeze dir if [:fs_freeze] end end |