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 +8 -8
- data/drebs.gemspec +1 -1
- data/lib/drebs.rb +1 -1
- data/lib/drebs/cloud.rb +9 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzE1MjM4ZjhlYzBjMmZkNGFkYmJlNGZjMmVmMWExYWI5ZDFlYzEyZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjUyYjgwNmQ2YzU0Y2Q4ZThiZTExNWI1MDRjY2Y0ZTAwZjJhNjUyYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWQzNDk4ZjQ5MDY2NTJkNmIwODk2YTcxYjFkZjZhMGIxNDQ0OTg1ZDBlY2Fl
|
10
|
+
MDE1ZWI0NmY2MDYzMmY3ZjdjZDg1OGRjMzkwMmZhZWRmOWIxNzFmZDJkYWQ1
|
11
|
+
YzUyZjdhNzVhMGJmYThlY2E3Yjg1ZTJkMDJhMDg2YzViNzQzN2E=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWZkMDc1MDI0ZTVjOTUwMzUyMWU2MTU2OTVmOGYyZWQxNWUxMGM0YWJhOWEz
|
14
|
+
OGIyMDg2Yjg3N2ViM2RiZThmYzM1ZjdiZGFiYWNlNTBjZDdiZTU3NWM3NDM4
|
15
|
+
ODE3ZDY0MGQyZGY3ZmRiNTRhMzNiNjVkMWEzNTQ5N2QzYzExODc=
|
data/drebs.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
Gem::Specification::new do |spec|
|
5
5
|
spec.name = "drebs"
|
6
|
-
spec.version = "0.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."
|
data/lib/drebs.rb
CHANGED
data/lib/drebs/cloud.rb
CHANGED
@@ -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 #{
|
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 #{
|
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 #{
|
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
|