Database Reference
In-Depth Information
bu_report += bu_header
puts bu_header
until it > num do
# iterate through 7 back-up files
(i.e., days)
bk_day = dy . to_i - it
# assemble backup filename
bu_file_suffix = yr + "-" + mon . downcase + "-" + bk_day . to_s
+ ".sql"
bu_file = bu_pre + bu_file_suffix
bu_path_file = bu_dir + bu_file
# get info. on back-up file if it exists
if File : :exists? ( bu_path_file )
bu_size = File . size? ( bu_path_file )
bu_size_human = bu_size / 1024
bu_file_entry = bu_file + " (" + bu_size_human . to_s + "k)"
bu_report += bu_file_entry + " \n "
puts bu_file_entry
end
it += 1
end
it = 0
end
end
begin
# insert report text accumulated in backup_reports table
con = Mysql . new host , user , password , database
sql = "INSERT INTO backup_reports
(report_date, admin_name, report)
VALUES (NOW(), ?, ?)"
prep_sql = con . prepare sql
prep_sql . execute ( admin_name , bu_report )
rescue Mysql : :Error => e
puts e . errno
puts e . error
ensure
con . close if con
end
Search WWH ::




Custom Search