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.
50 51 52 |
# File 'lib/ey_backup/dumper.rb', line 50 def initialize(database) @database = database end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
13 14 15 |
# File 'lib/ey_backup/dumper.rb', line 13 def database @database end |
Class Method Details
.run(databases, split_size) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ey_backup/dumper.rb', line 15 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' # we don't provide alert here unless its a failure unless alert_level == 'OKAY' .gsub!("\n", '\n') = Shellwords.escape().truncate(255) full_txt= "Severity: #{alert_level}\n" \ + "Time: #{Time.now.to_i}\n" \ + "Type: process-dbbackup summary\n" \ + "Plugin: exec\n" full_txt = Shellwords.escape(full_txt) full_txt += "raw_message:\\ \\'#{}\\'" alert_command = %Q(echo #{full_txt} | /engineyard/bin/ey-alert.rb 2>&1) system(alert_command) end end |
Instance Method Details
#run(split_size) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ey_backup/dumper.rb', line 54 def run(split_size) info("Doing database: #{@database.name}") backup_set = @database.dump backup_set.split!(split_size) backup_set.upload! okay(@database.name, @database.backup_size) backup_set.cleanup backup_set.rm! @database.backup_size end |