Database Reference
In-Depth Information
This Ruby program has comments throughout it to explain the various sections of the
code. However, I'd like to summarize it and highlight a few parts.
First, we get the current date to create variables that we'll use to determine the name of
back-up files. These are based on the backup policies shown in Table14-2 .
Skipping ahead, you can see that we create a variable, bu_report , for storing text for a
report. This report is displayed on the screen for the user as it goes along and will in the
end be inserted into the backup_reports table.
Going back to the first begin block, we execute a SELECT to get a list of backup
policies from the backup_policies table. This table includes the file format prefix
(e.g.,rookery-class-) used to make each backup file. This is followed by the date format
that each filename uses (yyyy-mm-dd.sql). We store these policies in a hash named
policies . Using an each statement, we go through each policy to form a header for
each and then execute an until statement to check for the backup files on the server for
the past week. For each backup file found, the bu_report is appended with the name of
the file and its size.
The next begin block executes an INSERT statement to save the contents of
bu_report , along with the date and the administrator's name in the
backup_reports table. The results for one sample row in that table follow:
*************************** 62. row ***************************
report_id: 62
report_date: 2014-10-20 14:32:37
admin_name: Lena Stankoska
report: Back-Up File Report
-----------------------------------------------------
rookery - full back-up (performed weekly)
(rookery-yyyy-mmm-dd.sql)
-----------------------------------------------------
rookery-2014-oct-20.sql (7476k)
rookery-2014-oct-13.sql (7474k)
rookery - bird classification (performed daily)
(rookery-class-yyyy-mmm-dd.sql)
-----------------------------------------------------
rookery-class-2014-oct-20.sql (2156k)
rookery-class-2014-oct-19.sql (2156k)
rookery-class-2014-oct-18.sql (2156k)
rookery-class-2014-oct-17.sql (2154k)
rookery-class-2014-oct-16.sql (2154k)
Search WWH ::




Custom Search