ebs_snapper 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/ebs_snapper/ebs.rb +4 -3
- data/lib/ebs_snapper/version.rb +1 -1
- data/spec/lib/ebs_spec.rb +14 -0
- metadata +10 -10
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# EbsSnapper
|
2
2
|
|
3
|
-
Take snapshots of EBS volumes and keep them for a period of time.
|
3
|
+
Take snapshots of EBS volumes and keep them for a period of time.
|
4
|
+
We use this to take nightly snapshots and retain them for several days before being purged.
|
4
5
|
|
5
6
|
|
6
7
|
|
data/lib/ebs_snapper/ebs.rb
CHANGED
@@ -32,7 +32,7 @@ class EbsSnapper::Ebs
|
|
32
32
|
# now snapshot the list
|
33
33
|
tagged_volumes.each do |vol_info|
|
34
34
|
snapshot_volume(vol_info[:region], vol_info[:volume_id])
|
35
|
-
purge_old_snapshots(vol_info[:region], vol_info[:volume_id])
|
35
|
+
purge_old_snapshots(vol_info[:ttl], vol_info[:region], vol_info[:volume_id])
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -69,7 +69,7 @@ class EbsSnapper::Ebs
|
|
69
69
|
region.snapshots.filter('volume-id', vol_id).filter('tag-key', @tag_name).each do |snapshot|
|
70
70
|
unless snapshot.status == :pending
|
71
71
|
ts = snapshot.tags[@tag_name]
|
72
|
-
if
|
72
|
+
if ttl.purge?(ts)
|
73
73
|
@logger.info {"Purging #{vol_id} snapshot: #{snapshot}"}
|
74
74
|
snapshot.delete
|
75
75
|
end
|
@@ -98,7 +98,8 @@ class EbsSnapper::Ebs
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def purge?(timestamp)
|
101
|
-
|
101
|
+
ts = timestamp.to_i
|
102
|
+
ts > 0 && (ts < @cut_off)
|
102
103
|
end
|
103
104
|
|
104
105
|
def convert_to_seconds(ttl)
|
data/lib/ebs_snapper/version.rb
CHANGED
data/spec/lib/ebs_spec.rb
CHANGED
@@ -46,6 +46,7 @@ describe EbsSnapper::Ebs do
|
|
46
46
|
ttl = EbsSnapper::Ebs::TTL.new("1.day") # 1 day
|
47
47
|
ttl.purge?(Time.now.utc.to_i - (86400 * 3)).should == true
|
48
48
|
ttl.purge?(Time.now.utc.to_i - (86400 + 3601)).should == true
|
49
|
+
ttl.purge?("#{Time.now.utc.to_i - (86400 + 3601)}").should == true
|
49
50
|
end
|
50
51
|
|
51
52
|
it "shouldn't pruge new timestamps" do
|
@@ -140,4 +141,17 @@ describe EbsSnapper::Ebs do
|
|
140
141
|
ebs.purge_old_snapshots(ttl, region, 2)
|
141
142
|
end
|
142
143
|
|
144
|
+
it "should flow through snapshot and purge" do
|
145
|
+
ebs = EbsSnapper::Ebs.new
|
146
|
+
ebs.stub(:tagged_volumes).and_return([{
|
147
|
+
:ttl => EbsSnapper::Ebs::TTL.new("1.day"),
|
148
|
+
:region => 'us-east-1',
|
149
|
+
:volume_id => 1
|
150
|
+
}])
|
151
|
+
|
152
|
+
ebs.should_receive(:snapshot_volume).with(anything(), anything()).once.and_return()
|
153
|
+
ebs.should_receive(:purge_old_snapshots).with(anything(), anything(), anything()).once.and_return()
|
154
|
+
|
155
|
+
ebs.snapshot_and_purge()
|
156
|
+
end
|
143
157
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ebs_snapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157108240 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157108240
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157106140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157106140
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157104840 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157104840
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: fakeweb
|
49
|
-
requirement: &
|
49
|
+
requirement: &2157103500 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2157103500
|
58
58
|
description: Manage snapshots of EBS volumes
|
59
59
|
email:
|
60
60
|
- ultradns@neustar.biz
|