Sha256: 7463300418bfd8ea60eed900f5a08dd747f2de56e679519138f9f883589bed9e

Contents?: true

Size: 815 Bytes

Versions: 5

Compression:

Stored size: 815 Bytes

Contents

require 'mail_builder'
require "socket"

class BackupReport
  
  def initialize from = ENV['USER'],to = "root",mail_options = {}
    
    backups = []
    
    Keepitsafe.after_backup do |backup,values|
      backups << backup
    end
    
    start_time = Time.now
    capture = STDCapture.capture do 
      yield
    end
    end_time = Time.now
    
    # Send email report
    mail = MailBuilder.new("#{File.dirname(__FILE__)}/../email/report").build({:backups => backups, :start_time => start_time, :end_time => end_time})
    mail.to to
    mail.from from
    mail.subject "Backup report: #{backups.select {|b| b.error != nil}.count} Error"
    mail.delivery_method.settings = mail.delivery_method.settings.merge(mail_options)
    mail.deliver!
    
    puts "\nSent backup report to: #{to}"
    
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
keepitsafe-0.2.6 lib/backup_report.rb
keepitsafe-0.2.5 lib/backup_report.rb
keepitsafe-0.2.4 lib/backup_report.rb
keepitsafe-0.2.3 lib/backup_report.rb
keepitsafe-0.2.2 lib/backup_report.rb