Oracle Backup and Recovery
Oracle Backup and Recovery
www.yogijicreations.com
Index
Backup and Need of it Different types of backup
Hot vs cold Full vs incremental Physical vs logical
Backup
What do we mean by database backup ?
The process of periodically taking a copy of the database and log file (and possibly programs) onto offline storage media.
www.yogijicreations.com
Solution :STARTUP Database and let Oracle automatically perform instance recovery using the online redo logs and undo data in the undo tablespace.
www.yogijicreations.com
www.yogijicreations.com
Media Failures
The loss of one or more database files (Datafiles, Control files, redo log files) The database file can be lost or corrupted for a number of reasons:
Failure of a disk drive Failure of a disk controller Inadvertent deletion or corruption of a database file
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
User-Managed Backups
The basic user-managed backup strategy is to make periodic backups of datafiles and archived logs with operating system commands.
Logical or physical. Physical: Backup of physical file structure (datafiles, control files..) Logical: backups of logical objects such as tables, views
Export / Import utility is used to take logical backup and restore it back.
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
The RMAN
Oracle provided utility for backing-up, restoring and recovering Oracle Databases Doesn't require a separate installation. Off-line and on-line database backups. Can not write directly to tape.
3rd-party tools (like Veritas, Omiback) can integrate with RMAN to handle tape library management.
www.yogijicreations.com
RMAN features
Compress backups of datafiles so that only those data blocks that have been written to are included in a backup Store frequently executed backup and recovery operations in scripts. Perform incremental backups Create a duplicate production database for testing purpose printable message log of all backup and recovery operations. Recovery catalog automates both restore and recovery operations Perform crosschecks
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
Control file
www.yogijicreations.com
Datafile 1 Datafile 2
Datafile 3
Control file
Datafile 4
Backup set 1
Backup set 2
Backup set 3
www.yogijicreations.com
Backup Set
Usually contain more than one file. Can be written to a disk or tape. Required to extract files for restoration Can be incremental or full. Do not include never-used blocks.
www.yogijicreations.com
Backup Piece
A backup piece is a file in a backup set. A backup piece can contain blocks from more than one datafile.
Backup set 1 (Logical) Piece 1 (file) Piece 2 (file)
Datafile 1 Datafile 4 Datafile 5
www.yogijicreations.com
RMAN commands
BACKUP Back up database files, archive logs, backups, or copies. CATALOG Add information about files to the repository. (10g+) CHANGE Update the status of a backup in the RMAN repository. CONFIGURE Persistent RMAN settings. CONNECT Connect to a recovery catalog or auxiliary database CROSSCHECK Check whether backup items still exist. DELETE Delete backups from disk or tape EXIT Exit the RMAN console LIST List backups and copies
www.yogijicreations.com
RMAN Commands
RECOVER Apply redo logs or incremental backups to a restored backup set (or copy) in order to update it to a specified time. REPORT Report backup status: database, files, backups RESTORE Restore files from an RMAN backup (or copy) RUN Some RMAN commands are only valid inside a RUN block. SET Settings for the current RMAN session. SHOW Display the current configuration SHUTDOWN Shutdown the database SQL Execute a PL/SQL procedure or SQL statement(not SELECT) STARTUP Startup the database ADVISE FAILURE Display repair options (11g Data Recovery Advisor) REPAIR FAILURE Repair database failures (11g Data Recovery Advisor)
www.yogijicreations.com
month_full_backup
Datafiles 1,3
Datafiles 2,4
week_full_backup Wednesday_1_backup
Datafile 3 Datafile 4 Datafile 1
Backup set
Backup set
Backup set
www.yogijicreations.com
www.yogijicreations.com
Archived Redo Log Backups Archived redo logs are essential for recovering an inconsistent backup. BACKUP ARCHIVELOG
www.yogijicreations.com
Database Recovery
Difference between restoring and recovering? Restoring: copying backup files from secondary storage (backup media) to disk. Recovering: process of applying redo logs to the database to roll it forward.
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
Copy backups of the damaged datafiles to their default location Recover the affected tablespace. RECOVER TABLESPACE users
Create a new, empty datafile to replace a damaged datafile that has no corresponding backup.
ALTER DATABASE CREATE DATAFILE '/disk1/users1.f' AS '/disk2/users1.f';
www.yogijicreations.com
www.yogijicreations.com
This feature enhances RMAN recovery by automatically creating and recovering datafiles that have never been backed up. Archive log files are still required
www.yogijicreations.com
data file #1
data file #2
RMAN
Control fle
www.yogijicreations.com
Whenever a change is made to the database, the Oracle database server writes the data and generates a redo record in the redo buffer
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
Flashback Database
Faster than traditional point-in-time recovery. Traditional recovery method: Backups and Redo logs Flashback Database is implemented using a new type of log file called the Flashback Database log. Oracle database server periodically logs before images of data blocks in the Flashback Database logs. The data block images are used to quickly back out changes to the database during Flashback Database. RVWR: similar to the LGWR (log writer) process. writes Flashback Database data to the Flashback Database logs.
www.yogijicreations.com
www.yogijicreations.com
www.yogijicreations.com
Flashback Drop
DROP command permanently removed objects from the database In Oracle 10g, a DROP command places the object in the recycle bin. You can restore the object from the recycle bin at any time. Flashback table emp to before drop; drop table emp PURGE;
www.yogijicreations.com
Recycle Bin
A recycle bin contains all the dropped database objects until,
Permanently drop them with the PURGE command. Recover the dropped objects with the FLASHBACK TABLE command. There is no room in the tablespace for new rows or updates to existing rows. The tablespace needs to be extended.
www.yogijicreations.com
Flashback Table
Flashback Table allows you to recover a table or tables to a specific point in time without restoring a backup. When you use the Flashback Table feature to restore a table to a specific point in time, all associated objects, such as, indexes, constraints, and triggers will be restored. FLASHBACK TABLE emp TO SCN 76230;
www.yogijicreations.com
www.yogijicreations.com
Questions ?
For queries: [email protected]
www.yogijicreations.com