Class: EbsSnapshotter::Snapshotter

Inherits:
Object
  • Object
show all
Defined in:
lib/ebs_snapshotter/snapshotter.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_path, volume_id) ⇒ Snapshotter

Returns a new instance of Snapshotter.



7
8
9
10
# File 'lib/ebs_snapshotter/snapshotter.rb', line 7

def initialize(config_path, volume_id)
  @volume_id = volume_id
  @aws_config = YAML::load(File.open(config_path))
end

Instance Method Details

#snapshotObject



12
13
14
15
16
17
18
# File 'lib/ebs_snapshotter/snapshotter.rb', line 12

def snapshot
  new_snapshot = connection.snapshots.new
  new_snapshot.description = "#{@volume_id} - #{Time.now}"
  new_snapshot.volume_id = @volume_id
  saved = new_snapshot.save
  raise "Failed to save snapshot for #{@volume_id}" unless saved 
end