module Snapscatter
Constants
- VERSION
Public Class Methods
copy(ec2, region, snapshot, description)
click to toggle source
# File lib/snapscatter.rb, line 29 def copy ec2, region, snapshot, description options = { source_region: region, source_snapshot_id: snapshot.id, description: description } response = ec2.client.copy_snapshot options copied_snapshot = ec2.snapshots[response.data[:snapshot_id]] copied_snapshot.tags.set snapshot.tags end
in_lock(consistency_spec) { || ... }
click to toggle source
consistency spec should look like the following (all parameters but host, optional) strategy: mongo, host: 127.0.0.1, port: 27017, usr: admin, pwd: 12345
# File lib/snapscatter.rb, line 58 def in_lock consistency_spec locker = Locker.new Snapscatter.parse_spec(consistency_spec) locker.lock begin yield ensure locker.unlock end end
list(ec2)
click to toggle source
# File lib/snapscatter.rb, line 25 def list ec2 ec2.snapshots.tagged('PurgeAllow').tagged_values('true') end
parse_spec(str)
click to toggle source
# File lib/snapscatter.rb, line 9 def parse_spec str str ||= "" spec = {} str.split(',').map do |i| k, v = i.split(':').map { |i| i.strip } spec[k.to_sym] = v end return spec end
purge(ec2, purge_after_days, list_only)
click to toggle source
# File lib/snapscatter.rb, line 41 def purge ec2, purge_after_days, list_only purged = [] snapshots = Snapscatter.list ec2 snapshots.each do |snapshot| purge_date = snapshot.start_time.to_date + purge_after_days # say "#{Date.today} > #{purge_date} == #{Date.today > purge_date}" if Date.today > purge_date snapshot.delete if not list_only purged << snapshot end end return purged end
targets(ec2)
click to toggle source
# File lib/snapscatter.rb, line 21 def targets ec2 ec2.volumes.tagged('Backup').tagged_values('true') end
Private Instance Methods
copy(ec2, region, snapshot, description)
click to toggle source
# File lib/snapscatter.rb, line 29 def copy ec2, region, snapshot, description options = { source_region: region, source_snapshot_id: snapshot.id, description: description } response = ec2.client.copy_snapshot options copied_snapshot = ec2.snapshots[response.data[:snapshot_id]] copied_snapshot.tags.set snapshot.tags end
in_lock(consistency_spec) { || ... }
click to toggle source
consistency spec should look like the following (all parameters but host, optional) strategy: mongo, host: 127.0.0.1, port: 27017, usr: admin, pwd: 12345
# File lib/snapscatter.rb, line 58 def in_lock consistency_spec locker = Locker.new Snapscatter.parse_spec(consistency_spec) locker.lock begin yield ensure locker.unlock end end
list(ec2)
click to toggle source
# File lib/snapscatter.rb, line 25 def list ec2 ec2.snapshots.tagged('PurgeAllow').tagged_values('true') end
parse_spec(str)
click to toggle source
# File lib/snapscatter.rb, line 9 def parse_spec str str ||= "" spec = {} str.split(',').map do |i| k, v = i.split(':').map { |i| i.strip } spec[k.to_sym] = v end return spec end
purge(ec2, purge_after_days, list_only)
click to toggle source
# File lib/snapscatter.rb, line 41 def purge ec2, purge_after_days, list_only purged = [] snapshots = Snapscatter.list ec2 snapshots.each do |snapshot| purge_date = snapshot.start_time.to_date + purge_after_days # say "#{Date.today} > #{purge_date} == #{Date.today > purge_date}" if Date.today > purge_date snapshot.delete if not list_only purged << snapshot end end return purged end
targets(ec2)
click to toggle source
# File lib/snapscatter.rb, line 21 def targets ec2 ec2.volumes.tagged('Backup').tagged_values('true') end