View File - UET Taxila

Download Report

Transcript View File - UET Taxila

Data and Database
Administration
Chapter 12
Modern Database Management
Outline

Data Recovery and Backup
Basic Recovery Facilities

A DBMS should provide four basic backup and
recovery facilities




Backup facilities
Journalizing facilities
Checkpoint facilities
Recovery Manager
Backup Facilities



A DBMS should produce a backup copy of entire
DB, plus control files and journals.
The copy should be stored in a secure place and
used to restore the DB in the event of
failures/loss/damage.
For backups, DBAs can use





Backup utilities available in (some) DBMS
Operating system commands
Export commands
SELECT … INTO SQL command
Other utilities
Backup Facilities (Contd.)

Database Backup Strategies


For large DBs, regular backups may be impractical (time
consuming).
Two ways of taking backup




Hot backup – when DB is not shutdown from use
Cold backup - when DB is shutdown from use
A database may be a critical system that should always be
available, so a cold backup is not practical.
Regular backups may be taken of dynamic data (a socalled hot backup where only selected portion of DB is
shutdown from use)
Backup Facilities (Contd.)



Backups of static/less frequently changing data
may be taken less often.
Incremental backups which record changes made
since last full backup, may be taken on interim
basis. Incremental backups take lesser time.
Database backup strategy depends on the
demands being placed on the database
system.
Journalizing Facilities

A DBMS must provide journalizing facilities to keep
an audit trail of transactions and database changes.



Transaction: a discrete unit of work that must be
completely processed or not processed at all within a
computer system. e.g., entering a customer record
In the event of failure, a consistent database state
can be re-established by using the information in the
journals together with the most recent complete
backup.
There are two types of journals or logs:


Transaction log
Database change log
Journalizing Facilities (Contd.)

Transaction log


It contains a record of the essential data for each
transaction that is processed against the database
Data typically recorded for a transaction include








transaction code or ID
Action or type of transaction (e.g. insert)
Time of transaction
Terminal number or user ID
Input data values
Tables and records accessed
Records modified
And possibly the old and new field values
Journalizing Facilities (Contd.)

Database Change log:

It contains the before-images and after-images of
records that have been modified by transactions.

Before-image


After-image


A copy of a record before it has been modified
A copy of the same record after it has been modified
Some systems also keep a security log which can
alert the DBA to any security violations.
Figure - Database audit trail
Transaction
Recovery action
DBMS
Effect of transaction or
recovery action
Database
(current)
Database
(backup)
Copy of
transaction
Transaction
Log
Copy of database affected
by transaction
Database
Change
log
Checkpoint Facilities





A facility by which DBMS periodically refuses to
accept any new transactions.
All transactions in progress are completed and the
journal files are updates.
At this point, system is in a quiet state, and the
database & transaction logs are synchronized.
The DBMS writes a special record (checkpoint record)
to log file which is like a snapshot of the state of
database.
The checkpoint record contains info necessary to
restart the system.
Checkpoint Facilities (Contd.)





Any dirty blocks (memory pages containing changes not
yet written to the disks) are written from memory to the
disk storage, ensuring that all changes made prior to
taking checkpoint have been written to long-term
storage.
DBMS may perform checkpoints automatically or in
response to user application programs.
Checkpoints should be taken frequently (several times
an hour).
In case of failures, it is often possible to resume
processing from the most recent checkpoint.
Thus only few minutes processing work must be
repeated, compared with several hours for a complete
restart of the day’s processing.
Recovery Manager



It is a module of the DBMS which restores
the database to a correct condition when a
failure occurs and which resumes processing
user requests.
The type of restart used depends on the
nature of the failure.
Recovery manager uses the logs as well as
the backup copy to restore the database