aebus 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README +4 -2
- data/aebus.gemspec +13 -14
- data/bin/aebus +8 -6
- data/lib/aebus.rb +94 -53
- data/lib/aebus/version.rb +1 -1
- data/lib/config/config.rb +5 -5
- data/lib/config/volume.rb +9 -9
- data/lib/ec2/snapshot.rb +12 -12
- metadata +12 -26
- data/lib/ec2/zones.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4961058fa793c8cccd9961a3d70f01e0b06436d
|
4
|
+
data.tar.gz: 5f9917ee6161fccaec5e1b74a2a71f1bb4308fb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f331ed5ca55071aa1da176411a3894100ed9c70e9138dedcb1870295fb8ee9a3ded016c08711b351a3271e8e978a5d567d419c71123c8568a03c7ab93d48a41
|
7
|
+
data.tar.gz: eca2695285ad5d95c371d11477f0f6a024d43974ff83db64ae6cd8665f2c42b226a98559d2569932c7ee03bb83c4a74b3880bd065bb64157e26f439020b7a532
|
data/README
CHANGED
@@ -12,9 +12,11 @@ A small gem that allows you to easily automate EC2 backups, included purging of
|
|
12
12
|
backup_time: 00:00:00
|
13
13
|
access_key_id: <your_access_key_id>
|
14
14
|
secret_access_key: <your_secret_access_key>
|
15
|
-
|
15
|
+
region: eu-west1
|
16
16
|
from_address: <your sender address, must be verified with SES>
|
17
|
-
to_address:
|
17
|
+
to_address:
|
18
|
+
- address 1
|
19
|
+
- address 2
|
18
20
|
backups:
|
19
21
|
daily:
|
20
22
|
enabled: true
|
data/aebus.gemspec
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
3
|
-
require
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'aebus/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'aebus'
|
7
7
|
s.version = Aebus::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = [
|
10
|
-
s.email = [
|
11
|
-
s.homepage =
|
12
|
-
s.summary =
|
13
|
-
s.description =
|
14
|
-
|
9
|
+
s.authors = ['Marco Sandrini']
|
10
|
+
s.email = ['nessche@gmail.com']
|
11
|
+
s.homepage = 'https://github.com/nessche/Aebus'
|
12
|
+
s.summary = 'Automated EC2 BackUp Software'
|
13
|
+
s.description = 'A tool to automate snapshot management in EC2'
|
14
|
+
s.license = 'MIT'
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = [
|
19
|
+
s.require_paths = ['lib']
|
20
20
|
|
21
|
-
s.add_dependency(
|
22
|
-
s.add_dependency(
|
23
|
-
s.add_dependency(
|
24
|
-
s.add_dependency("aws-ses", "~> 0.5.0")
|
21
|
+
s.add_dependency('commander', '~> 4.4')
|
22
|
+
s.add_dependency('parse-cron', '~> 0.1')
|
23
|
+
s.add_dependency('aws-sdk', '~> 2')
|
25
24
|
|
26
25
|
# specify any dependencies here; for example:
|
27
26
|
# s.add_development_dependency "rspec"
|
data/bin/aebus
CHANGED
@@ -6,7 +6,7 @@ require 'pathname'
|
|
6
6
|
require_relative '../lib/aebus'
|
7
7
|
|
8
8
|
|
9
|
-
DEFAULT_CONFIG_NAME =
|
9
|
+
DEFAULT_CONFIG_NAME = './aebus.yaml'
|
10
10
|
|
11
11
|
program :version, Aebus::VERSION
|
12
12
|
program :description, 'Automatic EC2 BackUp Software'
|
@@ -27,12 +27,13 @@ command :status do |c|
|
|
27
27
|
c.example 'Checks the status of vol1 and vol2', 'aebus status vol1 vol2'
|
28
28
|
|
29
29
|
c.when_called do |args, options|
|
30
|
-
options.default
|
30
|
+
options.default(
|
31
31
|
:config => DEFAULT_CONFIG_NAME
|
32
|
+
)
|
32
33
|
begin
|
33
34
|
FileTest.exist?(Pathname.new(options.config).realpath)
|
34
|
-
rescue Errno::ENOENT
|
35
|
-
puts (
|
35
|
+
rescue Errno::ENOENT
|
36
|
+
puts ('Configuration file not found')
|
36
37
|
exit(2)
|
37
38
|
end
|
38
39
|
aebus = Aebus::Core.new
|
@@ -53,12 +54,13 @@ command :backup do |c|
|
|
53
54
|
c.option '--[no-]purge', 'Do not purge expired backups, defaults to --purge'
|
54
55
|
c.option '--[no-]mail', 'Mails a report in case something was done, defaults to --mail'
|
55
56
|
c.when_called do |args, options|
|
56
|
-
options.default
|
57
|
+
options.default(
|
57
58
|
:config => DEFAULT_CONFIG_NAME,
|
58
59
|
:manual => false,
|
59
60
|
:purge => true,
|
60
61
|
:mail => true
|
61
|
-
|
62
|
+
)
|
63
|
+
raise ('Config file does not exist') unless FileTest.exist?(Pathname.new(options.config).realpath)
|
62
64
|
aebus = Aebus::Core.new
|
63
65
|
aebus.backup(args,options)
|
64
66
|
end
|
data/lib/aebus.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require '
|
5
|
-
require 'aws/ses'
|
4
|
+
require 'aws-sdk'
|
6
5
|
require_relative 'config/config'
|
7
6
|
require_relative 'aebus/version'
|
8
7
|
require_relative 'aebus/logging'
|
9
8
|
require_relative 'aebus/volume_status'
|
10
|
-
require_relative 'ec2/zones'
|
11
9
|
require_relative 'ec2/snapshot'
|
12
10
|
|
13
11
|
module Aebus
|
@@ -16,8 +14,10 @@ module Aebus
|
|
16
14
|
|
17
15
|
include Logging
|
18
16
|
|
19
|
-
AWS_NAME_TAG =
|
20
|
-
AEBUS_TAG =
|
17
|
+
AWS_NAME_TAG = 'Name'
|
18
|
+
AEBUS_TAG = 'Aebus'
|
19
|
+
|
20
|
+
|
21
21
|
|
22
22
|
def status(args, options)
|
23
23
|
@current_time_utc = Time.now.utc
|
@@ -25,15 +25,19 @@ module Aebus
|
|
25
25
|
logger.info("status check started at #{@current_time_utc}")
|
26
26
|
|
27
27
|
@config = Config::Config.new(File.join(File.dirname("."), options.config), @current_time_utc)
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
|
29
|
+
@ec2 = Aws::EC2::Client.new(
|
30
|
+
region: @config.defaults['region'],
|
31
|
+
credentials: {
|
32
|
+
access_key_id: @config.defaults['access_key_id'],
|
33
|
+
secret_access_key: @config.defaults['secret_access_key']
|
34
|
+
})
|
31
35
|
|
32
36
|
|
33
37
|
|
34
38
|
target_volumes = target_volumes(args)
|
35
39
|
|
36
|
-
abort(
|
40
|
+
abort('Configuration contains invalid volumes') unless validate_target_volumes(target_volumes)
|
37
41
|
|
38
42
|
status = check_status(target_volumes)
|
39
43
|
|
@@ -100,19 +104,20 @@ module Aebus
|
|
100
104
|
init_logger options
|
101
105
|
logger.info("backup started at #{@current_time_utc}")
|
102
106
|
|
103
|
-
@ec2 =
|
104
|
-
|
105
|
-
|
107
|
+
@ec2 = Aws::EC2::Client.new(
|
108
|
+
region: @config.defaults['region'],
|
109
|
+
credentials: Aws::Credentials.new(@config.defaults['access_key_id'], @config.defaults['secret_access_key'])
|
110
|
+
)
|
106
111
|
|
107
112
|
target_volumes = target_volumes(args)
|
108
113
|
|
109
|
-
abort(
|
114
|
+
abort('Configuration contains invalid volumes') unless validate_target_volumes(target_volumes)
|
110
115
|
|
111
|
-
if
|
116
|
+
if options.manual
|
112
117
|
|
113
118
|
target_volumes.each do |volume|
|
114
119
|
to_backup += 1
|
115
|
-
break unless backup_volume(volume, [EC2::AEBUS_MANUAL_TAG])
|
120
|
+
break unless backup_volume(volume, [EC2::AEBUS_MANUAL_TAG], @config.get_value_for_volume(volume.id, 'custom_tags'))
|
116
121
|
backed_up += 1
|
117
122
|
|
118
123
|
end
|
@@ -131,7 +136,7 @@ module Aebus
|
|
131
136
|
tags << EC2::AEBUS_AUTO_TAG
|
132
137
|
logger.info("Creating backup for volume #{target} with tags #{tags.join(',')}, max delay #{max_delay}")
|
133
138
|
to_backup +=1
|
134
|
-
break unless backup_volume(target, tags)
|
139
|
+
break unless backup_volume(target, tags, @config.get_value_for_volume(volume.id, 'custom_tags'))
|
135
140
|
backed_up += 1
|
136
141
|
else
|
137
142
|
logger.info("Volume #{target} does not need to be backed up")
|
@@ -140,7 +145,7 @@ module Aebus
|
|
140
145
|
end
|
141
146
|
|
142
147
|
snap_map = get_snapshots_map # we reload the map since we may have created more snapshots
|
143
|
-
if options.purge
|
148
|
+
if options.purge
|
144
149
|
target_volumes.each do |target|
|
145
150
|
volume = @config.volumes[target]
|
146
151
|
purgeable_snapshot_ids = volume.purgeable_snapshot_ids(snap_map[target])
|
@@ -151,7 +156,7 @@ module Aebus
|
|
151
156
|
end
|
152
157
|
end
|
153
158
|
else
|
154
|
-
logger.info(
|
159
|
+
logger.info('Skipping purging phase')
|
155
160
|
end
|
156
161
|
|
157
162
|
end
|
@@ -159,7 +164,7 @@ module Aebus
|
|
159
164
|
message = "Backup Completed at #{Time.now}. Checked #{target_volumes.count} volume(s), #{to_backup} to be backed up, #{backed_up} actually backed up, max delay detected #{max_delay}s, #{to_purge} purgeable snapshot(s), #{purged} purged"
|
160
165
|
logger.info(message)
|
161
166
|
puts(message)
|
162
|
-
if to_backup > 0 or to_purge > 0
|
167
|
+
if to_backup > 0 or to_purge > 0
|
163
168
|
send_report message
|
164
169
|
end
|
165
170
|
end
|
@@ -167,7 +172,7 @@ module Aebus
|
|
167
172
|
def target_volumes(args)
|
168
173
|
|
169
174
|
result = @config.volume_ids
|
170
|
-
if args && (args.count > 0)
|
175
|
+
if args && (args.count > 0)
|
171
176
|
result &= args
|
172
177
|
end
|
173
178
|
|
@@ -181,39 +186,56 @@ module Aebus
|
|
181
186
|
|
182
187
|
# backs up a given volume using the given time as part of the name and setting the given tags to the snapshot
|
183
188
|
# @param volume_id [String] the id of the volume to be backed up
|
184
|
-
# @param
|
189
|
+
# @param aebus_tags [Array] an array of String to be used as tags for the snapshot
|
190
|
+
# @param custom_tags [Hash] a Hash containing custom tags to be added to the snapshot
|
185
191
|
# @return [boolean] true if the backup was successful, false otherwise
|
186
|
-
def backup_volume(volume_id,
|
192
|
+
def backup_volume(volume_id, aebus_tags, custom_tags = {})
|
187
193
|
begin
|
188
|
-
volume_info = @ec2.describe_volumes(:
|
194
|
+
volume_info = @ec2.describe_volumes(volume_ids: [volume_id])
|
189
195
|
|
190
|
-
rescue
|
196
|
+
rescue Aws::EC2::Errors::ServiceError => e
|
191
197
|
logger.error("Volume Id #{volume_id} not found. Underlying message #{e.message}")
|
192
198
|
return false
|
193
199
|
end
|
194
200
|
|
195
201
|
begin
|
196
|
-
|
197
|
-
volume_tags =
|
202
|
+
|
203
|
+
volume_tags = volume_info.volumes[0].tags
|
198
204
|
|
199
205
|
name_and_desc = Core.name_and_desc(volume_id, volume_tags, @current_time_utc)
|
200
|
-
create_response = @ec2.create_snapshot(:
|
206
|
+
create_response = @ec2.create_snapshot({volume_id: volume_id, description: name_and_desc[1]})
|
201
207
|
|
202
|
-
rescue
|
208
|
+
rescue Aws::EC2::Errors::ServiceError => e
|
203
209
|
logger.error("Volume Id #{volume_id} could not be backed up. Underlying message #{e.message}")
|
204
210
|
return false
|
205
211
|
end
|
206
212
|
|
207
213
|
begin
|
208
214
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
215
|
+
tags = [
|
216
|
+
{
|
217
|
+
key: AWS_NAME_TAG,
|
218
|
+
value: name_and_desc[0]
|
219
|
+
},
|
220
|
+
{
|
221
|
+
key: AEBUS_TAG,
|
222
|
+
value: aebus_tags.join(',')
|
223
|
+
}
|
224
|
+
]
|
225
|
+
|
226
|
+
if custom_tags
|
227
|
+
custom_tags.each_pair { |k, v| tags << {key: k, value: v} }
|
228
|
+
end
|
229
|
+
|
230
|
+
puts custom_tags
|
231
|
+
|
232
|
+
@ec2.create_tags(resources: [create_response.snapshot_id], tags: tags)
|
233
|
+
rescue Aws::EC2::Errors::ServiceError => e
|
234
|
+
logger.error("[WARNING] Could not set tags to snapshot #{create_response.snapshot_id}. Underlying message #{e.message}")
|
213
235
|
return false
|
214
236
|
end
|
215
237
|
|
216
|
-
logger.info("Created snapshot #{create_response.
|
238
|
+
logger.info("Created snapshot #{create_response.snapshot_id} for volume #{volume_id}")
|
217
239
|
|
218
240
|
true
|
219
241
|
|
@@ -226,16 +248,16 @@ module Aebus
|
|
226
248
|
# @return [Array] an array in the form of [name, description]]
|
227
249
|
def self.name_and_desc(volume_id, tags, utc_time)
|
228
250
|
|
229
|
-
name = "backup_#{utc_time.strftime(
|
251
|
+
name = "backup_#{utc_time.strftime('%Y%m%d')}_#{volume_id}"
|
230
252
|
volume_name = volume_id
|
231
253
|
tags.each do |tag|
|
232
|
-
if tag[
|
233
|
-
volume_name = tag[
|
254
|
+
if tag['key'].eql?(AWS_NAME_TAG)
|
255
|
+
volume_name = tag['value']
|
234
256
|
break
|
235
257
|
end
|
236
258
|
end
|
237
259
|
|
238
|
-
description = "Backup for volume #{volume_name} taken at #{utc_time.strftime(
|
260
|
+
description = "Backup for volume #{volume_name} taken at #{utc_time.strftime('%Y-%m-%d %H:%M:%S')}"
|
239
261
|
|
240
262
|
return [name, description]
|
241
263
|
|
@@ -243,9 +265,9 @@ module Aebus
|
|
243
265
|
|
244
266
|
def get_snapshots_map
|
245
267
|
|
246
|
-
response = @ec2.describe_snapshots(:
|
247
|
-
return Hash.new unless response.
|
248
|
-
snap_array = response.
|
268
|
+
response = @ec2.describe_snapshots(owner_ids: ['self'])
|
269
|
+
return Hash.new unless response.snapshots
|
270
|
+
snap_array = response.snapshots
|
249
271
|
result = Hash.new
|
250
272
|
snap_array.each do |snap|
|
251
273
|
snapshot = EC2::Snapshot.new(snap)
|
@@ -273,7 +295,7 @@ module Aebus
|
|
273
295
|
else
|
274
296
|
false
|
275
297
|
end
|
276
|
-
rescue
|
298
|
+
rescue Aws::EC2::Errors::ServiceError => e
|
277
299
|
logger.warn("Could not purge snapshot #{snapshot_id}; underlying message #{e.message}")
|
278
300
|
false
|
279
301
|
end
|
@@ -281,11 +303,12 @@ module Aebus
|
|
281
303
|
end
|
282
304
|
|
283
305
|
def validate_target_volumes(target_volumes)
|
306
|
+
logger.info(target_volumes)
|
284
307
|
begin
|
285
|
-
@ec2.describe_volumes(:
|
286
|
-
logger.info(
|
308
|
+
@ec2.describe_volumes({volume_ids: target_volumes})
|
309
|
+
logger.info('Target volumes validated')
|
287
310
|
true
|
288
|
-
rescue
|
311
|
+
rescue Aws::EC2::Errors::ServiceError => e
|
289
312
|
logger.error("Target validation failed with message '#{e.message}' Check your configuration")
|
290
313
|
false
|
291
314
|
end
|
@@ -297,21 +320,39 @@ module Aebus
|
|
297
320
|
logger.warn('Tried to send a message, but no message was specified')
|
298
321
|
return
|
299
322
|
end
|
300
|
-
to_address = @config.defaults[
|
301
|
-
|
323
|
+
to_address = @config.defaults['to_address']
|
324
|
+
if to_address.instance_of? String
|
325
|
+
to_address = [to_address]
|
326
|
+
end
|
327
|
+
from_address = @config.defaults['from_address']
|
302
328
|
if to_address.nil? or from_address.nil?
|
303
329
|
logger.warn('Tried to send a message but either to or from address where missing from configuration')
|
304
330
|
return
|
305
331
|
end
|
306
|
-
ses =
|
307
|
-
:
|
308
|
-
:
|
332
|
+
ses = Aws::SES::Client.new(
|
333
|
+
region: @config.defaults['region'],
|
334
|
+
credentials: Aws::Credentials.new(@config.defaults['access_key_id'], @config.defaults['secret_access_key'])
|
309
335
|
)
|
310
336
|
logger.info("Sending report to #{to_address} from account #{from_address}")
|
311
|
-
ses.send_email
|
312
|
-
|
313
|
-
|
314
|
-
|
337
|
+
ses.send_email({
|
338
|
+
destination: {
|
339
|
+
to_addresses: to_address
|
340
|
+
},
|
341
|
+
source: from_address,
|
342
|
+
message: {
|
343
|
+
subject: {
|
344
|
+
charset: 'UTF-8',
|
345
|
+
data: 'Aebus Report'
|
346
|
+
},
|
347
|
+
body: {
|
348
|
+
text: {
|
349
|
+
charset: 'UTF-8',
|
350
|
+
data: message
|
351
|
+
}
|
352
|
+
}
|
353
|
+
}
|
354
|
+
})
|
355
|
+
|
315
356
|
|
316
357
|
end
|
317
358
|
|
data/lib/aebus/version.rb
CHANGED
data/lib/config/config.rb
CHANGED
@@ -15,10 +15,10 @@ module Aebus
|
|
15
15
|
def initialize(filename, current_time_utc)
|
16
16
|
|
17
17
|
yaml_root = YAML::load(File.open(filename))
|
18
|
-
raise
|
18
|
+
raise 'Cannot find configuration file' unless yaml_root
|
19
19
|
|
20
20
|
@defaults = yaml_root.delete(DEFAULT_STRING)
|
21
|
-
default_backups = BackupSchedule.parse_backups_config(current_time_utc, @defaults[
|
21
|
+
default_backups = BackupSchedule.parse_backups_config(current_time_utc, @defaults['backups'])
|
22
22
|
|
23
23
|
@volumes = Hash.new
|
24
24
|
yaml_root.each_pair do |k, v|
|
@@ -40,14 +40,14 @@ module Aebus
|
|
40
40
|
|
41
41
|
def get_value_for_volume(volume_id, key)
|
42
42
|
result = nil
|
43
|
-
if
|
44
|
-
if
|
43
|
+
if @volumes.include? volume_id
|
44
|
+
if @volumes[volume_id].config.include? key
|
45
45
|
result = @volumes[volume_id].config[key]
|
46
46
|
else
|
47
47
|
result = @defaults[key]
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
result
|
51
51
|
end
|
52
52
|
|
53
53
|
|
data/lib/config/volume.rb
CHANGED
@@ -4,7 +4,7 @@ module Aebus
|
|
4
4
|
|
5
5
|
module Config
|
6
6
|
|
7
|
-
KEEP_ALL =
|
7
|
+
KEEP_ALL = 'all'
|
8
8
|
|
9
9
|
class BackupSchedule
|
10
10
|
|
@@ -12,17 +12,17 @@ module Aebus
|
|
12
12
|
|
13
13
|
def initialize (current_time_utc, label, backup_config)
|
14
14
|
@label = label
|
15
|
-
if
|
16
|
-
calculate_deadlines(current_time_utc, backup_config[
|
15
|
+
if backup_config['enabled']
|
16
|
+
calculate_deadlines(current_time_utc, backup_config['when'])
|
17
17
|
end
|
18
|
-
@keep = backup_config[
|
18
|
+
@keep = backup_config['keep']
|
19
19
|
# we use Infinity to model the keep all
|
20
20
|
@keep = 1.0 / 0 if (@keep.nil? || @keep.eql?(KEEP_ALL))
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def calculate_deadlines(current_time_utc, when_string)
|
25
|
-
raise(ArgumentError,
|
25
|
+
raise(ArgumentError, 'when field cannot be empty if the backup is enabled') unless when_string
|
26
26
|
|
27
27
|
parser = CronParser.new (when_string)
|
28
28
|
@last_deadline = parser.last(current_time_utc)
|
@@ -59,8 +59,8 @@ module Aebus
|
|
59
59
|
@config = config
|
60
60
|
@id = volume_id
|
61
61
|
@backups = default_backups ? default_backups.dup : Hash.new
|
62
|
-
if
|
63
|
-
@backups.merge(BackupSchedule.parse_backups_config(current_time_utc,config[
|
62
|
+
if config && config['backups']
|
63
|
+
@backups.merge(BackupSchedule.parse_backups_config(current_time_utc,config['backups']))
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -83,7 +83,7 @@ module Aebus
|
|
83
83
|
return false unless snapshots
|
84
84
|
snapshots.each do |snapshot|
|
85
85
|
|
86
|
-
if
|
86
|
+
if snapshot.aebus_tags_include?(label) && (snapshot.start_time > last_deadline)
|
87
87
|
return true
|
88
88
|
end
|
89
89
|
|
@@ -98,7 +98,7 @@ module Aebus
|
|
98
98
|
available_backups = @backups.each_with_object({}) { | (k, v) , h | h[k] = v.keep}
|
99
99
|
removables.each do |snapshot|
|
100
100
|
snapshot.aebus_tags.each do |tag|
|
101
|
-
if (
|
101
|
+
if (available_backups.include? tag) && (available_backups[tag] > 0) then
|
102
102
|
snapshot.keep = true
|
103
103
|
available_backups[tag] -= 1
|
104
104
|
end
|
data/lib/ec2/snapshot.rb
CHANGED
@@ -2,10 +2,10 @@ module Aebus
|
|
2
2
|
|
3
3
|
module EC2
|
4
4
|
|
5
|
-
AEBUS_TAG =
|
6
|
-
AEBUS_MANUAL_TAG =
|
7
|
-
AEBUS_KEEP_TAG =
|
8
|
-
AEBUS_AUTO_TAG =
|
5
|
+
AEBUS_TAG = 'Aebus'
|
6
|
+
AEBUS_MANUAL_TAG = 'manual'
|
7
|
+
AEBUS_KEEP_TAG = 'keep'
|
8
|
+
AEBUS_AUTO_TAG = 'auto'
|
9
9
|
|
10
10
|
class Snapshot
|
11
11
|
|
@@ -15,16 +15,16 @@ module Aebus
|
|
15
15
|
|
16
16
|
def initialize(hash)
|
17
17
|
|
18
|
-
raise(ArgumentError,
|
18
|
+
raise(ArgumentError, 'hash cannot be nil') unless hash
|
19
19
|
@keep
|
20
|
-
@id = hash.
|
21
|
-
@start_time =
|
22
|
-
@volume_id = hash.
|
20
|
+
@id = hash.snapshot_id
|
21
|
+
@start_time = hash.start_time
|
22
|
+
@volume_id = hash.volume_id
|
23
23
|
@tags = Hash.new
|
24
|
-
if
|
25
|
-
tag_array = hash.
|
24
|
+
if hash.tags
|
25
|
+
tag_array = hash.tags
|
26
26
|
tag_array.each do |tag|
|
27
|
-
@tags.store(tag
|
27
|
+
@tags.store(tag.key,tag.value)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -34,7 +34,7 @@ module Aebus
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def aebus_tags_include?(label)
|
37
|
-
if aebus_snapshot?
|
37
|
+
if aebus_snapshot?
|
38
38
|
return aebus_tags.include? label
|
39
39
|
end
|
40
40
|
false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aebus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Sandrini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -16,56 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
19
|
+
version: '4.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.
|
26
|
+
version: '4.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: parse-cron
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.1
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.1
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: amazon-ec2
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
33
|
+
version: '0.1'
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
40
|
+
version: '0.1'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: aws-
|
42
|
+
name: aws-sdk
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
47
|
+
version: '2'
|
62
48
|
type: :runtime
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
54
|
+
version: '2'
|
69
55
|
description: A tool to automate snapshot management in EC2
|
70
56
|
email:
|
71
57
|
- nessche@gmail.com
|
@@ -87,9 +73,9 @@ files:
|
|
87
73
|
- lib/config/config.rb
|
88
74
|
- lib/config/volume.rb
|
89
75
|
- lib/ec2/snapshot.rb
|
90
|
-
- lib/ec2/zones.rb
|
91
76
|
homepage: https://github.com/nessche/Aebus
|
92
|
-
licenses:
|
77
|
+
licenses:
|
78
|
+
- MIT
|
93
79
|
metadata: {}
|
94
80
|
post_install_message:
|
95
81
|
rdoc_options: []
|
@@ -107,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
93
|
version: '0'
|
108
94
|
requirements: []
|
109
95
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.6.10
|
111
97
|
signing_key:
|
112
98
|
specification_version: 4
|
113
99
|
summary: Automated EC2 BackUp Software
|
data/lib/ec2/zones.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Aebus
|
2
|
-
|
3
|
-
module EC2
|
4
|
-
|
5
|
-
ZONES = {
|
6
|
-
|
7
|
-
"eu-west1" => "eu-west-1.ec2.amazonaws.com",
|
8
|
-
"us-east-1" => "ec2.us-east-1.amazonaws.com",
|
9
|
-
"us-west-1" => "ec2.us-west-1.amazonaws.com",
|
10
|
-
"ap-southeast-1" => "ec2.ap-southeast-1.amazonaws.com"
|
11
|
-
}
|
12
|
-
|
13
|
-
def self.zone_to_url(zone)
|
14
|
-
ZONES[zone]
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|