drebs 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzZmNzdhMDEzZDQ0YmNhNzMxYzY2NTcyOTRjMzA0NmY4OGRiYzllNg==
4
+ YzE1MjM4ZjhlYzBjMmZkNGFkYmJlNGZjMmVmMWExYWI5ZDFlYzEyZg==
5
5
  data.tar.gz: !binary |-
6
- MTJkZTJiMmJiYjYxYmU4ODQ4OWRiNjYwNTMwZjQzZWYxYjk1MzMzNw==
6
+ ZjUyYjgwNmQ2YzU0Y2Q4ZThiZTExNWI1MDRjY2Y0ZTAwZjJhNjUyYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTU2MWMzYjhmMjU3ZDc2NzFiNGZlYjkwMWNjNzhiZGZkN2YyNTI3NGVmOTgy
10
- MGY5NTllYzVhOTlhZGNkOWFjOTkwNDdlZmE1MmViNzU4MzllNjI3OGJhNWU2
11
- MWRmZTY2OGYyNGI3NjljNDJjMzQ3OWM1YTI3MmRhMTdlNTE1MjY=
9
+ OWQzNDk4ZjQ5MDY2NTJkNmIwODk2YTcxYjFkZjZhMGIxNDQ0OTg1ZDBlY2Fl
10
+ MDE1ZWI0NmY2MDYzMmY3ZjdjZDg1OGRjMzkwMmZhZWRmOWIxNzFmZDJkYWQ1
11
+ YzUyZjdhNzVhMGJmYThlY2E3Yjg1ZTJkMDJhMDg2YzViNzQzN2E=
12
12
  data.tar.gz: !binary |-
13
- Y2FlZGU0NjlkNzU3NzMwNDVjYjgyZGQxNjY4NGU0YzJiNjZkODdmZGQzNmVk
14
- YjQyNzU2OTgxZTMyZTIyZDEyNjM2NDA3ZjNjYWU2ZWNjNGNhNDFhMmQ1ZjQ5
15
- NGMwNThmOGFkMzAzM2EzY2QyZTE3MGNiYjA0YWZjYWNiMWVmNmI=
13
+ ZWZkMDc1MDI0ZTVjOTUwMzUyMWU2MTU2OTVmOGYyZWQxNWUxMGM0YWJhOWEz
14
+ OGIyMDg2Yjg3N2ViM2RiZThmYzM1ZjdiZGFiYWNlNTBjZDdiZTU3NWM3NDM4
15
+ ODE3ZDY0MGQyZGY3ZmRiNTRhMzNiNjVkMWEzNTQ5N2QzYzExODc=
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "drebs"
6
- spec.version = "0.1.1"
6
+ spec.version = "0.1.2"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "drebs"
9
9
  spec.description = "drebs: Disaster Recovery for Elastic Block Store. An AWS EBS backup script."
@@ -5,7 +5,7 @@
5
5
  # DREBS libs
6
6
  #
7
7
  module DREBS
8
- Version = '0.1.1' unless defined?(Version)
8
+ Version = '0.1.2' unless defined?(Version)
9
9
 
10
10
  def version
11
11
  DREBS::Version
@@ -1,4 +1,5 @@
1
1
  require 'right_aws'
2
+ require 'date'
2
3
 
3
4
  module Drebs
4
5
  class Cloud
@@ -46,22 +47,26 @@ module Drebs
46
47
  return a_snapshot if a_snapshot[:aws_id] == snapshot_id
47
48
  }
48
49
  end
49
-
50
+
50
51
  def create_local_snapshot(pre_snapshot_tasks, post_snapshot_tasks, mount_point)
51
52
  local_instance=find_local_instance
52
53
  ip = local_instance[:ip_address]
53
54
  instance_id = local_instance[:aws_instance_id]
55
+ instance_tags = ec2.describe_tags(:filters => {"resource-id" => instance_id})
56
+ instance_name_tag = instance_tags.find{|t| t[:key] == "Name"}
57
+ instance_desc = instance_name_tag.nil? ? ip : instance_name_tag[:value]
54
58
  volume_id = local_instance[:block_device_mappings].select{|m| m[:device_name]==mount_point}.first[:ebs_volume_id]
59
+ timestamp = DateTime.now.strftime("%Y%m%d%H%M%S")
55
60
  return nil if not ebs = find_local_ebs(mount_point)
56
61
  pre_snapshot_tasks.each do |task|
57
62
  result, stdout, stderr = systemu(task)
58
63
  unless result.exitstatus == 0
59
64
  raise Exception.new(
60
- "Error while executing pre-snapshot task: #{task} on #{ip}:#{mount_point} #{instance_id}:#{volume_id} "
65
+ "Error while executing pre-snapshot task: #{task} on #{instance_desc}:#{mount_point} #{instance_id}:#{volume_id} at #{timestamp}"
61
66
  )
62
67
  end
63
68
  end if pre_snapshot_tasks
64
- snapshot = ec2.create_snapshot(ebs[:ebs_volume_id], "DREBS #{ip}:#{mount_point} #{instance_id}:#{volume_id}")
69
+ snapshot = ec2.create_snapshot(ebs[:ebs_volume_id], "DREBS #{instance_desc}:#{mount_point} #{instance_id}:#{volume_id} at #{timestamp}")
65
70
  Thread.new(snapshot[:aws_id], post_snapshot_tasks) do |snapshot_id, post_snapshot_tasks|
66
71
  1.upto(500) do |a|
67
72
  sleep(3)
@@ -71,7 +76,7 @@ module Drebs
71
76
  result = systemu(task)
72
77
  unless result.exitstatus == 0
73
78
  raise Exception.new(
74
- "Error while executing post-snapshot task: #{task} on #{ip}:#{mount_point} #{instance_id}:#{volume_id} "
79
+ "Error while executing post-snapshot task: #{task} on #{instance_desc}:#{mount_point} #{instance_id}:#{volume_id} at #{timestamp}"
75
80
  )
76
81
  end
77
82
  end if post_snapshot_tasks
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drebs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garett Shulman