Backup & Recovery
| Article Index |
|---|
| 1. RMAN Repository |
| 2. Types of Records in the Control File |
| 3. Recovery Catalog |
| 4. Managing RMAN Repository |
RMAN maintain metadata in repository about target database, its backup and recovery operations. For example (own configuration setting, target database schema, archived redo logs and backup files on disk or tap).
1. RMAN Repository
- RMAN maintain metadata about target DB, it backup and recovery operations. For example (own configuration setting, target DB schema, archived redo logs and backup files on disk or tap.
- Primary storage is control file of the target DB.
- Another copy of RMAN repository can also saved in recovery catalog.
- LIST, REPORT, SHOW displays repository information.
- CONTROL_FILE_RECORD_KEEP_TIME parameter specifies in days after how record will be reused for new records in a control file. Default is 7 days.
- If you back up the whole database once a week, then you need to set value at least 7 days
- If the file is eligible for deletion then database attempts to delete file from flash recovery area. Otherwise, the database expands the size of the control file, logging the expansion in the alert log with a message like this example:
kccwnc: trying to expand control file section nnnn for Oracle Managed Files - If the control file is at the maximum size supported under the host operating system, then the database cannot expand the control file. This warning appears in the alert log
WARNING: Oracle Managed File filename is unknown to control file.
Recovery Without a Recovery catalog : Oracle recommends that you:
- Enable control file autobackup feature
- Keep a record of your DBID
- Use a minimum of two multiplexed or mirrored control files on separate disks
- Keep all Recovery Manager backup logs.
2. Types of Records in the Control File
Circular Reuse Records:
Contain noncritical information that is eligible to be overwritten. The CONTROL_FILE_RECORD_KEEP_TIME initialization parameter specifies the minimum age in days of a record before it can be reused.
Noncircular Reuse Records:
Contain critical information that can not be overwritten such as (datafiles, online redo logs, and redo threads)
3. Recovery Catalog
- Preserve RMAN repository information if control file is lost.
- Can store much more history of backup then control file.
- Can also hold RMAN stored scripts and sequence of RMAN commands for common backup tasks.
- Except of stored scripts all features works well in both options.
- Can hold data for one or more databases in a separate DB schema.
-
The tablespace that holds the repository database requires at least 125MB to hold recovery catalog entries; Starting out with available free space of 125MB will in most cases be sufficient for the first year, and enabling additional extents of 50MB each will be sufficient in the long term depending on how many databases you manage in the recovery catalog.
Contents of the Recovery Catalog :
The recovery catalog contains information about RMAN operations, including:
- Datafile and archived redo log backup sets and backup pieces
- Datafile copies
- Archived redo logs and their copies
- Tablespaces and datafiles on the target database
- Stored scripts, which are named user-created sequences of RMAN commands
- Persistent RMAN configuration settings
Operations of Recovery Catalog
Create recovery catalog [ CREATE CATALOG ]:
- SYS can not be the owner of catalog.
- Don’t use target DB for recovery catalog. Must be protected.
- ARCHIVE log mode is recommended for catalog.
- Ensure catalog and target DB do not reside on same disk.
- Assign separate table-space for recovery catalog schema.
1 |
CONNECT SYS/DEV@DEVDB AS SYSDBA |
Register DB in Recovery catalog [ REGISTER DATABASE / CATALOG ]:
- Registering database copies all repository data about target DB control file to recovery catalog.
- Multiple targets can be catalog.
- RMAN uses DBID to distinguish one DB from another.
1 |
RMAN> CONNECT TARGET SYS/SRDC@TEST1 -- connect with target database |
- Older file (data-file copies back-up piece, archive-log) can also be cataloged.
- Only oracle 8 and higher files can be cataloged.
- Oracle 7 files can also be cataloged but must be consistent.
1 |
RMAN> CATALOG DATAFILE 'C:\OLDBACKUP\USER01.DBF'; -Single DATA file |
Un-Register target database [ UNREGISTER DATABASE / DELETE ]:
- When database is un-registered from the catalog all records in recovery catalog are lost.
- Can be registering again based on the contents of the control files at the time registration.
- It is not necessary to connect the target database, but if you do not use SET DBID
1 |
RMAN> CONNECT TARGET SYS/SRDC@TEST1 -- connect with target database |
- If you want to delete all backups of the database. These following commands will delete file physically and removes entries from catalog.
1 |
RMAN> DELETE BACKUP DEVICE TYPE sbt; --Delete all backups from tap drive |
Resetting DB Incarnation in the recovery catalog
- The SQL statement ALTE DATABASE OPEN RESTLOGS create new incarnation of the DB.
- Records of new incarnation can be access using V$DATABASE_INCARNATION view
- When you issue command ALTE DATABASE OPEN RESTLOGS incarnation record automatically created in catalog.
- And DB issue RESET DATABASE command automatically.
- All subsequent backups and log archiving done by the target DB associated with the new DB incarnation.
- You may need to change the current incarnation for some recovery tasks.
1 |
RMAN> LIST INCARNATION OF DATABASE TEST1;-- Obtain incarnation key (Inc Key) |
Removing DELETED records form catalog after Upgrade; [ PRGRMANC.SQL ]:
- In oracle 9i and later RMAN always removes catalog records on deleting files.
- In releases prior to oracle 9i RMAN show status DELETED after deleting the physical files.
- If you upgrade repository prior to oracle 9i then you need to set DELETED status. By using a SQL scripts
- This script removes all records with the status DELETED.
1 |
SQL> CONNECT RMAN/CAT@DEVDB -- Connect to recovery catalog |
Resynchronize the Recovery Catalog; [ RESYNC CATALOG ]:
- When RMAN performs a resynchronization it compares recovery catalog to control file with information that is missing or changed.
- RMAN perform resynchronization automatically as needed. But resynchronization can also do manually.
- In partial resynchronization RMAN reads current control file to update change information (new backups, new archive log) and does not resynchronize metadata (physical schema, data-file, table-spaces, redo-threads, rollback-segments).
- In full resynchronization RMAN updates all changed records.
- Resynchronize after physical database change.
- If you maintain recovery catalog the use RESYNC CATALOG often enough before they are reused.
- If set CONTROL_FILE_RECORD_KEEP_TIME = 7 days you muse resynchronize before 7 days
1 |
RMAN> CONNECT TARGET SYS/SRDC@TEST1 -- connect with target database |
Backing up and recovering the recovering catalog:
If you do not backup the recovery catalog and a disk failure occurs and destroy recovery catalog then it will be very difficult to recovery the database. There are three possible ways to recover the recovery catalog.
- Enable Archive log mode and take backups like any other DB and recover the recovery catalog in case of failure.
- Use export and import utility to recreate or move catalog.
- Don’t run CREATE CATALOG command either before or after import.
- Export recovery catalog.
EXP rman/cat@devdb FILE=cat.dmp OWNER=rman
- Create recovery catalog user.
- Import recovery catalog dump.
- IMP USERID=rman2/cat2@devdb FILE=cat.dmp FROMUSER=rman TOUSER=rman2
- Re-Create Recovery Catalog from existing backups
- Create new catalog in the new database.
- Register target database.
- Use RESYNC CATALOG command.
- Issue CATLOG START WITH …. Commands to re-catalog any backups
Backup the recovery catalog as the same frequency as you backup.
4. Managing RMAN Repository
RMAN repository metadata is always stored in the control file of the target database. You can also create a recovery catalog in a separate database, and RMAN will record its metadata there as well.
Monitoring Control File Records
If you do not use a recovery catalog, then eventually RMAN control file records are overwritten. Set this initialization parameter in the parameter file of the target database to determine how long records are kept:
1 |
CONTROL_FILE_RECORD_KEEP_TIME = number_of_days_to_keep
|
Crosschecking Backups
The CROSSCHECK command checks whether RMAN backups and copies in the repository are still readable by RMAN. Assuming that you have configured automatic channels, you can run these commands:
1 |
RMAN> CROSSCHECK BACKUP; # checks RMAN backups on configured devices |
If backups are stored with a media manager and sbt channels are not configured, then you must allocate a maintenance channel before CROSSCHECK and DELETE commands on sbt devices:
1 |
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt; |
Deleting Backups Created with RMAN
The DELETE command removes RMAN backups and copies from DISK and sbt devices, marks the objects as DELETED in the control file, and removes the records from the recovery catalog (if you use a catalog). For example:
1 |
RMAN> DELETE BACKUPSET 101, 102, 103; |
The following options of the DELETE command are also useful:
Parameter |
Example |
Explanation |
|
EXPIRED |
DELETE EXPIRED |
Deletes the backups and copies marked as EXPIRED (that is, "not found") by the CROSSCHECK command. |
|
OBSOLETE |
DELETE OBSOLETE |
Deletes the backups and copies that are obsolete under the retention policy. REDUNDANCY and RECOVERY WINDOW parameters override the configured policy. |
|
NOPROMPT |
DELETE NOPROMPT OBSOLETE |
Specifies that you do not want to be prompted to confirm the files to be deleted. |
Cataloging and Uncataloging Backups and Copies
The CATALOG command adds information about useable backups to the RMAN repository. Use this command to record backups created with tools other than RMAN, such as datafile copies created with operating system-level utilities. You can also use this command if you have backups which are created using RMAN but which are no longer listed in the RMAN repository. RMAN can use these backups in restore and recovery operations. For example:
1 |
## copy made with operating system copy cmd |
Note: that the second example adds all usable backups where the filepath begins with /backup to the RMAN repository, including files in the directory /backup/users01.bak, files in subdirectories such as /backup/tuesday/users01.bak.old, and files in directories whose name starts with /backup, such as /backup-2001/users01.bak.old. Take care when choosing your argument for CATALOG LIKE.
The CHANGE ... UNCATALOG syntax lets you remove information about backups and copies from the RMAN repository. If you manually delete a backup using operating system commands, CHANGE...UNCATALOG updates the repository to reflect that change. For example:
RMAN> CHANGE CONTROLFILECOPY '/tmp/cf.cpy' UNCATALOG;
RMAN> CHANGE BACKUPSET 121,122,127,203,300 UNCATALOG;
Related Articals:
- Introduction to RMAN [Part-1]
- Backup and recovery operations using RMAN (Part-2)
- Using RMAN Repository (Part-3)
| Latest Articles |
