Class: EY::Backup::Dumper
- Includes:
- Logging
- Defined in:
- lib/ey_backup/dumper.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(database) ⇒ Dumper
constructor
A new instance of Dumper.
- #run(split_size) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(database) ⇒ Dumper
Returns a new instance of Dumper.
40 41 42 |
# File 'lib/ey_backup/dumper.rb', line 40 def initialize(database) @database = database end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
7 8 9 |
# File 'lib/ey_backup/dumper.rb', line 7 def database @database end |
Class Method Details
.run(databases, split_size) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ey_backup/dumper.rb', line 9 def self.run(databases, split_size) exceptions = [] completed = [] databases.each do |database| begin backup_size = new(database).run(split_size) completed << "#{database.name} (#{backup_size})" rescue => e puts e exceptions << database.name next end end = '' = + "Failures: #{exceptions}" if ! exceptions.empty? = + ", " if ! exceptions.empty? and ! completed.empty? = + "Completed successfully: #{completed}" if ! completed.empty? alert_level=exceptions.empty? ? 'OKAY' : 'FAILURE' .gsub!("\n", '\n') full_txt= "Severity: #{alert_level}\n" \ + "Time: #{Time.now.to_i}\n" \ + "Type: process-dbbackup summary\n" \ + "Plugin: exec\n" \ + "raw_message: '#{}'" full_txt = Shellwords.escape(full_txt) alert_command = %Q(echo #{full_txt} | /engineyard/bin/ey-alert.rb 2>&1) system(alert_command) end |
Instance Method Details
#run(split_size) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ey_backup/dumper.rb', line 44 def run(split_size) info("Doing database: #{@database.name}") backup_set = @database.dump backup_set.split!(split_size) backup_set.upload! okay("Successful backup: #{@database.name} (#{@database.backup_size})", @database.name) backup_set.cleanup backup_set.rm! @database.backup_size end |