Sha256: d0f14192b832b53806ddd916eb6acb4e81a4af578ebfdb5dce4063c3ca50badf

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 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"
    mail.delivery_method.settings = mail.delivery_method.settings.merge(mail_options)
    mail.deliver!
    
    puts "Sent backup report to: #{to}"
    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
keepitsafe-0.2.1 lib/backup_report.rb
keepitsafe-0.2.0 lib/backup_report.rb