Presentation is loading. Please wait.

Presentation is loading. Please wait.

M ODULE 3 D ATABASE M ANAGEMENT Section 5 Database Backup and Recovery 1 ITEC 450 Fall 2012.

Similar presentations


Presentation on theme: "M ODULE 3 D ATABASE M ANAGEMENT Section 5 Database Backup and Recovery 1 ITEC 450 Fall 2012."— Presentation transcript:

1 M ODULE 3 D ATABASE M ANAGEMENT Section 5 Database Backup and Recovery 1 ITEC 450 Fall 2012

2 I NTRODUCTION TO B ACKUP AND R ECOVERY Backup is the process of making some kind of copies of parts of a database, or an entire database Recovery is the process of rebuilding a database after some part of a database has been lost Restoration is the process of copying files from a backup Recovery is the process of executing procedures in Oracle Database to update the recovered backup files to an up to date state Fall 2012 2 ITEC 450

3 W HAT IS B ACKUP ? Fall 2012 3 ITEC 450

4 W HAT IS R ESTORATION ? Fall 2012 4 ITEC 450

5 C ATEGORIES OF D ATABASE F AILURES Instance failures – service interruption, no data loss DBMS internal exception Operating system failure Hardware-related failures except storage media: CPU, Memory board, disk controller Human error – hardest to prevent, data issue Programs are run at the wrong time, wrong order, or wrong input Media failure – data unavailable, recovery needed Disk damage, file system failures, data file deletion Tape degradation or damage Fall 2012 5 ITEC 450

6 D ATABASE B ACKUP C HOICES Backup strategies are driven by the recovery requirements. Full and incremental backups Full – a complete copy at the time the backup was run. Incremental (differential) – the backup of changes since the last full or incremental backup Consistent and inconsistent backups Consistent – the data in the backup is from a same point in time Inconsistent – the backup is done while the database is open and there are changes Physical and logical backups Physical – copy physical data files to a backup device Logical – export of (selected) data from database to a file or a backup device Fall 2012 6 ITEC 450

7 B ACKUP G UIDELINES The DBA must assure a recoverable environment. Make at least two copies of backup to avoid a single point of failure such as a damaged tape Coordinate local backup strategy with disaster recovery strategy Consider backups to disk, and then migrating to tape Be sure to include the system catalog objects in the backup Verify the correctness of the backup once a while Database data and application metadata should be backed up at the same time. Fall 2012 7 ITEC 450

8 B ACKUP L EVELS AND C OVERAGE Backup levels Level 0 (full) – a full backup of the database: all physical files associate the database Level 1 (cumulative) – a backup of all of the data that has changed since the last level 0 backup Level 2 (incremental) – a backup of all of the data that has changed since the last backup of any level (0, 1 or 2) Backup coverage Log archiving – it is required for up-to-time recovery System catalog – containing backup and recovery information Database object definition – It’s nice to have it over time to track what changed, and be able to recreate objects if necessary Fall 2012 8 ITEC 450

9 R ECOVERY S TEPS Identify the failure Analyze the situation Determine what needs to be recovered Locate the required image copy backup Restore the image copy backup Roll forward through the database log Fall 2012 9 ITEC 450

10 R ECOVER TO C URRENT Recovery to current usually responds to a media failure, such as accidentally deleted, or disk crashed. Restored database can be from full, cumulative, and/or incremental. Fall 2012 10 ITEC 450

11 P OINT -I N -T IME R ECOVERY The PIT recovery responds non-media failures, such as application-level problem or user error. It will restore the whole database back to the time before the error. All changes between the time of the error and current will be rolled back. Recovery description: Restore whole database backup Apply the database change logs from the time of backup to the time just before the error Open the database as the moment before the error Fall 2012 11 ITEC 450

12 W HAT IS R ECOVERY ? Redo logs and archive logs consist of records of all transactions made to a database Controlfiles contain pointers to datafiles, dictating where datafiles should be in relation to redo log entries If a datafile is restored from a backup, then the controlfile will be ahead of the datafile in time Restoration of recovered backup is a simple process of applying redo log entries to the datafile, until the datafile “catches up” to the time indicated by controlfile Archive logs are copies of old redo log files, copied just before redo log files are reused Restoration can utilize entries in both redo log files and archive log files to complete a recovery Fall 2012 12 ITEC 450

13 T RANSACTION R ECOVERY Transaction recovery addresses an error from a specific transaction. respond non-media failures, such as application-level problem or user error. Recovery options are: PIT recovery – remove all changes including the error and other transactions UNDO recovery – remove only the effects of the bad transaction REDO recovery – PIT recovery and then redo the good transactions only Fall 2012 13 ITEC 450

14 A LTERNATIVES TO B ACKUP AND R ECOVERY Other high-availability alternatives can be used: Standby database or database mirroring – an identical copy of an online production database that is close to being up-to-date. Data replication or transactional replication – storing and maintaining redundant data in a separate database Hardware redundancy with disk replication locally or remotely – allocating a secondary device that contains a duplicate copy of the primary device Fall 2012 14 ITEC 450

15 D ISASTER P LANNING Disaster recovery planning, also called contingency planning is the process for: Any unplanned, extended loss of critical business applications due to lack of computer processing capabilities for more than a 48-hour period. Any event that has a small chance of transpiring, a high-level of uncertainty, and a potentially devastating outcome. Examples: floods, earthquakes, hurricanes, fires, terrorist attacks Fall 2012 15 ITEC 450

16 D ISASTER R ECOVERY G UIDELINES The goals are to minimize downtime and loss of data. Analyze business risks, and not technical needs and issues Rank applications into groups Plan for enterprise wide business functions and operational activities Build an off-site location Establish a written plan and distribute to all key personnel Testing disaster plans Fall 2012 16 ITEC 450

17 D ATABASE P LANNING FOR D ISASTER R ECOVERY Database strategies for disaster recovery: Tape backups, and ship them to the remote site Storage management software to make point-in- time copies of entire disk packs Remote mirroring of data to the alternate site over the network Standby or database mirroring at a different physical site from the primary database location Fall 2012 17 ITEC 450

18 M ODULE 3 D ATABASE M ANAGEMENT Section 6 Oracle Backup and Recovery 18 ITEC 450 Fall 2012

19 B ACKUP AND R ECOVERY C ONCEPTS Archivelog and noarchivelog modes Archivelog – Oracle saves the filled redo logs as archivelogs. You may recover the database to any point in time. Noarchivelog – Oracle overwrites the filled redo logs. You can’t recover the database changes since the last cold backup took place. Restoring and Recovery Restoring a database means copying the physical files from a backup medium. Recovery is the process of updating database files restored from a backup with the changes made to the database after the backup, typically using redo log files. Fall 2012 19 ITEC 450

20 C ONSISTENT AND I NCONSISTENT B ACKUPS Consistent Backups (closed, cold) To make a consistent backup, the database is shutdown cleanly and remain closed for the duration of the backup. All committed changes are written to the datafiles, so the datafiles are in a transaction-consistent sate. When you restore your datafiles from a consistent backup, you can open the database immediately. Inconsistent Backups (open, online, hot) If a database is in ARCHIVELOG mode, then you can make inconsistent backups that are recoverable using archived redo log files. The redo logs must be archived and then backed up with the datafiles to ensure recoverability. An inconsistent backup is robust a form of backup as a consistent backup. It is common for production environments. Fall 2012 20 ITEC 450

21 M ETHODS OF B ACKUP AND R ECOVERY Two basic methods of backup and recovery: Cold backups Hot backups Fall 2012 21 ITEC 450

22 T OOLS FOR B ACKUP AND R ECOVERY Tools used for backup and recovery of an Oracle database are as follows: Export and Import Utilities Backup Mode Tablespace Copies RMAN (Recovery Manager) Oracle Enterprise Manager and the Database Control Fall 2012 22 ITEC 450

23 W HAT IS A C OLD B ACKUP ? Fall 2012 23 ITEC 450

24 C OLD B ACKUPS For a cold backup, shut down the database completely and then copy all the files All datafiles All redo log files All archive log files All controlfiles Optionally you can also back up parameter files and any networking configuration files Restore at least all the datafiles and controlfiles Optionally use more current redo log files, archive log files, and controlfiles—allowing a recovery by applying redo log entries to datafiles Fall 2012 24 ITEC 450

25 W HAT IS A H OT B ACKUP ? Hot backup: performed when DB is online, active, and available for use Many tools and methods for performing hot backups Takes a snapshot of a database one file or type of file at a time Not necessarily consistent across all files in backup Made of pieces of a DB, where those files making up a complete DB backup are not recoverable to a working database as a group Individual files can be slotted into a running DB, and can be recovered individually, or as a group Fall 2012 25 ITEC 450

26 S ETTING THE D ATABASE IN A RCHIVE L OG M ODE In archive log mode, the database will create archive logs for you Archive logs are files that are copied from redo logs when a redo log file is switched out for recycling Redo logs contain entries of all transactional activity in a database as transactions occur Redo logs are recycled If a redo log is recycled, unless the redo log is copied to an archive log, all entries in that redo log group are effectively lost A database must be in archive log mode to duplicate redo logs to archive logs Fall 2012 26 ITEC 450

27 S ETTING THE D ATABASE IN A RCHIVE L OG M ODE ARCHIVE LOG LIST; ARCHIVE LOG STOP; SHUTDOWN IMMEDIATE; STARTUP MOUNT; ALTER DATABASE NOARCHIVELOG; ALTER DATABASE OPEN; SHUTDOWN IMMEDIATE; STARTUP MOUNT; ALTER DATABASE ARCHIVELOG; ALTER DATABASE OPEN; Fall 2012 27 ITEC 450

28 C ONSISTENT B ACKUPS U SING E XPORTS Export can be used to create a consistent backup Export can scan through all types of data, including tables, redo and archive logs, and undo data Allows for a consistent backup (export) based on a snapshot of data In other words, regardless of any changes occurring to DB, during an export, the export utility will read datafiles and undo space to get a consistent backup Examples: exp system/ @oraclass file=classmate.dat owner=classmate consistent=Y exp classmate/classpass@oraclass file=classmatetables.dat tables=(client,customer) Fall 2012 28 ITEC 450

29 T ABLESPACE B ACKUPS In a tablespace backup, you switch a tablespace into a special mode called backup mode This allows a physical operating system-level copy of that tablespace In Oracle 10 g, allows a backup mode setting to be applied to all tablespaces at once Problem with backup mode is a performance issue Forces all change activity for that tablespace to be copied to the redo logs If there are enough redo entries produced to recycle a redo log group, then archive log files will be used too The longer a tablespace remains in backup mode, the more performance is affected, the longer any potential recovery is, and more redo log data is produced Fall 2012 29 ITEC 450

30 O THER A PPROACHES TO B ACKUP AND R ECOVERY Fall 2012 30 ITEC 450

31 C ONFIGURATION OF B ACKUP AND R ECOVERY Configure a flash recovery area – storing most backup related files Run database in ARCHIVELOG mode It is required for online backup It enables recovery options such as compete and point-in-time media recovery RMAN is the backup and recovery tool for Oracle database. Fall 2012 31 ITEC 450

32 O RACLE R ECOVERY S TRATEGY Response to media failure – recovery to current Response to non-media failure – PIT recovery, flash back Instance failure – Oracle performs instance recovery automatically: all you need to do is restart the database. A power outage causes the server to crash The server becomes unavailable because of hardware problems The operating system crashes One of the Oracle background processes fails. You issue a SHUTDOWN ABORT statement Fall 2012 32 ITEC 450

33 W RAP U P Assignment 8-1 Using a specific DBMS example to present database security management Hands-on practice to understand Oracle security: create a user, try to login and create a table Detailed steps are on the course website Assignment 3-1-3: Lab3 – Backup and Recovery Reference to “assginment3-1-3 help.pdf”, otherwise take you a lot of effort to read Oracle documents Hands-on practice: Cold backup Hands-on practice: Hot backup Challenges and technical Fall 2012 33 ITEC 450


Download ppt "M ODULE 3 D ATABASE M ANAGEMENT Section 5 Database Backup and Recovery 1 ITEC 450 Fall 2012."

Similar presentations


Ads by Google