Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Backup and Recovery

Similar presentations


Presentation on theme: "Database Backup and Recovery"— Presentation transcript:

1 Database Backup and Recovery
One problem: media flaws. Note that if you’re overwriting a file with a newer version of the same, and you hit a bad block, neither the old or new is consistent.

2 Keeping backups E.g., Daily backups for 7 days, then weekly backups for 8 weeks, then monthly backups for 12 months, then yearly backups. Keep backups off-site RAID reduces failures, but doesn’t give backups Losing 1 day might be unacceptable! Reconstruct instantaneous backups via log files. RU keeps two copies of Fri backup, one off-site. How would *you* do try to keep all data working?

3 Log Files “Dear journal: today I updated phone# for…”
Captures all database transactions (changes) in order to roll a database forward after a tape recovery. Oracle logs each :old and :new Log files should be stored on a separate drive from the data files Log files in Oracle can be multiplexed (mult copies); less common since RAID does this. Every entry in the log has a system-change-number (a sequence used for updates)

4 Log Modes No Archive Log Mode Archive Log Mode
Also called circular logging When the final redo log file in a set fills up, the first redo log file is overwritten Lacks: guaranteed point in time recovery Archive Log Mode The on-line redo logs are archived and numbered before they overwritten Allows point-in-time recovery of the database Requires: more disks ($$)

5 Backup Modes Hot backup Cold backup
allows backup of the database while the database is running and available to users. performance degrades during the backup period takes longer than a cold backup Cold backup requires database shutdown before backup begins physical files are backed up while shutdown database is unavailable to users during backup period faster than a hot backup; no timing issues

6 Oracle Backup Options Off-line physical backup On-line physical backup
is a cold backup technique copies data files, log files, init files, and control files after shutdown On-line physical backup is a hot backup technique temporarily sets tablespaces into backup mode Logical Backup exports all or part of the database by creating SQL scripts necessary to recreate the objects

7 Off-line physical backup
Shut down the database Backup the data files Backup the control files Backup the online redo log files or the archive log files Backup the initialization and password files Restart the database

8 On-line physical backup
Requires the DB to be in Archive Log Mode For each tablespace Set the tablespace into a backup state: read-only, but keep log Backup the datafiles for that tablespace Restore the tablespace to its normal state Backup the archived redo log files Stop the archiving process Note which files are in the archive log directory Restart the archiving process Delete the archived redo log files Backup the control file using the “Alter database backup controlfile” command Backup the initialization and password files E.g. One tablespace for accounting tables, another for registration, etc. DB Admin can assign tablespaces to particular discs. While the table is in backup-mode, any reads read the frozen version followed by the change log. When backing up, it’ll remember the transaction# when the backup started, and backup *all* table spaces to that same point, so that the backup-across-all-tablespaces is consistent. Companies will do test-recoveries in a sandbox; "The only thing worse than not backing up is to *think* you were backing up”. When bob's boss comes saying "I had an two days ago but accidentally deleted it. Please recover." The program didn't have an option ' best sol'n (Microsoft Exchange server, which sits on top of SQL server, which runs in archive log mode) -- they made a utility which xfers the backup tape to the disc, used to be one-message-per-file, but that doesn't scale. Now, mail are databases. (e.g. Entourage).

9 Logical Backup Back up tables -- not disks/files per se
Essentially creates SQL scripts that will recreate database objects Use Oracle Export Utility to create .dmp file Use Oracle Import Utility to selectively import database objects from the .dmp file Can perform Complete database backup User (schema) backup Individual table backup Used in conjunction with a recovery server to recover selected objects (not entire database) easy; can be done by end-user: "begin transaction; select * [write to disk]; end transact" Oracle's the .dmp file includes all triggers, , etc. (In a physical backup, you back up files; in a logical database, you back up objects. much slower than a file-level backup.) "Backups are why database administrators are well-paid". In certification courses, there are several exams; one exam is *just* on backing up and restoring. Hurricane Andrew -- 70% of companies that lost their data were bankrupt within 3mos (they had no idea what customers owed them money -- or even what customers they have!) Ask to raise hands: how many people have lost a hw due to a lost file? how many people have had a hard drive fail? how many haven't?

10 Backup Types Complete (Full) Cumulative (Differential) Incremental
copy all database and related files delete the archive log files Cumulative (Differential) copy all archive log files Essentially copies transactions since last full backup clear the archive bit on the log files Incremental copy all archive log files that haven’t already been backed up Essentially copies all transactions since last backup of any kind clear the archive bit on the log files copied Complete (Copy) copy all target data Don’t delete or clear the archive bit on an data files so as not to interfere with normal backup schedule oracle approaches incremental backups by block: each block has a bit 'has this block changed' Another approach: just backup the archive log files for that day. A "differential backup" includes all changes since last full backup; a "incremental backup" only includes changes since last incremental. So suppose: Sunday you did full backup; monday incremental; adn tues afternoon you have a failure. What steps do you need? (three). What if you made a incremental on Tuesday -- how many steps? (four) What if you had done a diff *and* incremental on tues -- only need three steps: sunday restore; tuesday diff [from sunday]; then back up from live log files. The "complete (copy)" is something not part of your usual routine -- it's something you do just do to make a sandbox restore or something. Because RU is part of Oracle Initiative, there is a 40% discount on courses and exams. Studies show that some certifications have some small value, and others are useless. Often when you get a job, the first thing the company will do is send you to a training course.

11 Oracle Files Overview 343 342 341 1 2 A B C PW Password File
Files open when instance is running PW 343 342 341 Password File Data files (for tablespace data) 1 2 A B C Archive Log Files Init. ora Initialization File Control Files On-line redo log files


Download ppt "Database Backup and Recovery"

Similar presentations


Ads by Google