aebus 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -9,9 +9,12 @@ A small gem that allows you to easily automate EC2 backups, included purging of
9
9
  ==== Sample
10
10
 
11
11
  default:
12
+ backup_time: 00:00:00
12
13
  access_key_id: <your_access_key_id>
13
14
  secret_access_key: <your_secret_access_key>
14
15
  zone: eu-west1
16
+ from_address: <your sender address, must be verified with SES>
17
+ to_address: <a comma separated list of addresses>
15
18
  backups:
16
19
  daily:
17
20
  enabled: true
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency("commander", "~> 4.0.6")
22
22
  s.add_dependency("parse-cron", ">= 0.1.1")
23
23
  s.add_dependency("amazon-ec2", "~> 0.9.17")
24
+ s.add_dependency("aws-ses", "~> 0.4.4")
24
25
 
25
26
  # specify any dependencies here; for example:
26
27
  # s.add_development_dependency "rspec"
data/bin/aebus CHANGED
@@ -51,11 +51,13 @@ command :backup do |c|
51
51
  c.example 'Create, if needed, backups for all volumes', 'aebus backup'
52
52
  c.option '-m', '--manual', 'Starts a manual backup (always creates a snapshot for each volume)'
53
53
  c.option '--[no-]purge', 'Do not purge expired backups, defaults to --purge'
54
+ c.option '--[no-]mail', 'Mails a report in case something was done, defaults to --mail'
54
55
  c.when_called do |args, options|
55
56
  options.default \
56
57
  :config => DEFAULT_CONFIG_NAME,
57
58
  :manual => false,
58
- :purge => true
59
+ :purge => true,
60
+ :mail => true
59
61
  raise ("Config file does not exist") unless FileTest.exist?(Pathname.new(options.config).realpath)
60
62
  aebus = Aebus::Core.new
61
63
  aebus.backup(args,options)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'AWS'
5
+ require 'aws/ses'
5
6
  require_relative 'config/config'
6
7
  require_relative 'aebus/version'
7
8
  require_relative 'aebus/logging'
@@ -155,7 +156,9 @@ module Aebus
155
156
  message = "Backup Completed at #{Time.now}. Checked #{target_volumes.count} volume(s), backed up #{backed_up}, max delay detected #{max_delay}, #{to_purge} purgeable snapshot(s), #{purged} purged"
156
157
  logger.info(message)
157
158
  puts(message)
158
-
159
+ if to_backup > 0 or to_backup > 0 then
160
+ send_report message
161
+ end
159
162
  end
160
163
 
161
164
  def target_volumes(args)
@@ -284,6 +287,29 @@ module Aebus
284
287
 
285
288
  end
286
289
 
290
+ def send_report(message)
291
+ if message.nil? then
292
+ logger.warn("Tried to send a message, but no message was specified")
293
+ return
294
+ end
295
+ to_address = @config.defaults["to_address"]
296
+ from_address = @config.defaults["from_address"]
297
+ if to_address.nil? or from_address.nil? then
298
+ logger.warn("Tried to send a message but either to or from address where missing from configuration")
299
+ return
300
+ end
301
+ ses = AWS::SES::Base.new(
302
+ :access_key_id => @config.defaults["access_key_id"],
303
+ :secret_access_key => @config.defaults["secret_access_key"]
304
+ )
305
+ logger.info("Sending report to #{to_address} from account #{from_address}")
306
+ ses.send_email :to => [to_address],
307
+ :source => from_address,
308
+ :subject => "Aebus Report",
309
+ :text_body => message
310
+
311
+ end
312
+
287
313
  end
288
314
 
289
315
  end
@@ -1,3 +1,3 @@
1
1
  module Aebus
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aebus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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: 2011-11-28 00:00:00.000000000Z
12
+ date: 2011-12-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
16
- requirement: &70278571512580 !ruby/object:Gem::Requirement
16
+ requirement: &70244299589980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.0.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70278571512580
24
+ version_requirements: *70244299589980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: parse-cron
27
- requirement: &70278571512080 !ruby/object:Gem::Requirement
27
+ requirement: &70244299589460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.1.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70278571512080
35
+ version_requirements: *70244299589460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: amazon-ec2
38
- requirement: &70278571511620 !ruby/object:Gem::Requirement
38
+ requirement: &70244299589000 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,18 @@ dependencies:
43
43
  version: 0.9.17
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70278571511620
46
+ version_requirements: *70244299589000
47
+ - !ruby/object:Gem::Dependency
48
+ name: aws-ses
49
+ requirement: &70244299588540 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.4.4
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70244299588540
47
58
  description: A tool to automate snapshot management in EC2
48
59
  email:
49
60
  - nessche@gmail.com