Recovery Manager (RMAN)
RMAN can do everything a normal backup can do, however RMAN has its own backup catalog to record the backups that took place. The database can be in two formats archivelog mode or nonarchivelog mode
There are several types of backup
The benefits to using RMAN are
RMAN Architecture
RMAN operates via a server session connecting to the target database, it gets the metadata from the target, this is called the RMAN repository. The repository will contain information on
The Recovery Catalog
RMAN will use the controlfile on the target database to store repository information regarding any backups for that server, this information can also be stored in a recovery catalog (optional) which resides on a rman server its own database (default size should be about 115MB) which should be dedicated to RMAN, information is still written to controlfile even if a recovery catalog is used.
The information stored in the controlfile is stored in the reusable sections called circular reuse records and non-circular reuse records. The circular reuse records have non-critical information that can be overwritten if needed. Some of the non-circular re-useable sections consists of data files and redo log information. RMAN can backup archive logs, controlfile, data files, spfile and tablespaces it does not backup temporary tablespaces, redo logs, password file, init.ora.
The controlfile based repository will retain data for only the time specified by the instance parameter CONTROL_FILE_RECORD_KEEP_TIME this defaults to seven days.
Useful View |
|
V$CONTROLFILE_RECORD_SECTION | displays information about the control file record sections |
Media Management Layer
If you backup to tapes you require additional software called MML (media management layer) or media manager. MML is a API that interfaces with different vendors tape libraries.
RMAN terminology
Connecting to RMAN
There are a number of ways to connect to RMAN and it depends on where the recovery catalog is
set the Oracle SID | c:\> set ORACLE_SID=D01 ORACLE_SID=D01; export ORACLE_SID |
connect to the target server use oracle_sid and local controlfile | c:\> rman c:\> rman target=sys/<password>@d01 |
connect the recovery manager catalog | rman> connect catalog rman_user/password@d01 |
connect target & recovery manager catalog | rman> connect target orcl catalog rman_user/password@d01 |
Configuring RMAN persistent settings
RMAN’s persistent settings which are stored in the controlfile (reason why must be in mount mode) of the target database (#default means that parameter is at default setting) or a recovery catalog if used
Format options | You can use format options with backup commands to specify a location and name for backup pieces %F - combines database identifier (DBID), day, month, year and sequence number |
Displaying | rman> show all CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default |
set default device to be a tape drive | configure default device type to sbt; |
set default device to be a disk drive | configure default device type to disk; |
set default backup to be a image copy | configure device type disk backup type to copy; |
default disk backup to a compressed backupset (upto 20% ratio) | configure device type disk backup type to compressed backupset; |
default tape backup to a compressed backupset (upto 20% ratio) | configure device type sbt backup type to compressed backupset; |
Set degree of parallelism | configure device type disk parallelism 4; configure device type sbt parallelism 4; |
Backup optimization | configure backup optimization on; Note: this will ensure that RMAN doesn't perform a backup if it has already backed up identical versions. |
My basic rman config | CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS |
Channel Parameters/Options
The parameters/options are use to control the resources used by RMAN, there are many options probably best to consult the oracle documentation.
examples | rman> configure channel device type disk format ‘s:\ora_backup\ora_dev_f%t_s%s_s%p’; |
Backup Retention
Default is redundancy 1 which means always attempt to have one backup image or backupset of every data file, archive log and controlfile
keep backups for 30 days | rman> configure retention policy to recover window of 30 days; |
keep aleast 2 copies | rman> configure retention policy to redundancy 2; |
reset back to 1 (default) | rman> configure retention policy clear; |
extend the retention period | rman> change backupset tag monthly_backup keep until time ’01-dec-07’ logs; |
Backup Tagging
examples | rman> backup database tag “monthly_backup”; |
Controlfile Backup
examples | rman> backup current controlfile; rman> configure controlfile autobackup format for device type disk to ‘z:\orabackup\controlfile_%F’; |
Tablespace Excludes
examples | rman> configure exclude from tablespace test; (exclude test tablespace from backup) |
Creating Backups
Backup Sets | rman> run { rman> run { rman> backup as compressed backupset database; rman> backup as backupset copy of tablespace sysaux; (create a backupset from a image copy) |
Backup Images | rman> run { rman> backup as copy database; |
Parallel Streams | rman> configure device type disk parallelism 3; (must have 3 channels) Note : You only configure the number of streams to the number of channels, if you configure more they will not start. Remember that you need multiple channels configured to use the streams. |
Backup controlfile and spfile to flash recovery area | # need to clear the 'controlfile autoback format' then the flash recovery area will be used. rman> configure controlfile autobackup format for device type disk clear rman> backup current controlfile; |
Other examples | rman> backup device type disk copies 2 datafile 1 format ''disk1/df1_%U', '/disk2/df1_%U'; Note: |
Validating/Cross Checking Backups
You can validate a backup set before you restore which ensures that backup files exist in the proper locations and that they are readable and free from any logical and physical corruptions, you can also crosscheck backup sets to make sure they are available and have not been deleted (backup sets can be deleted from the operating system level).
Validate a backup | rman> validate backupset 1; |
crosscheck | rman> crosscheck backupset 1; |
Viewing backups
The v$ views information regarding backups is always located in the target database’s or target database’s controlfile.
The list commands are used to determine files impacted by the change, crosscheck and delete commands. The report command is accurate when the control and RMAN repository are synchronized which can be performed by the change, crosscheck and delete commands
list all image copies | rman> list copy; rman> list archivelog all; |
list all backups | rman> list backup; rman> list backupset by backup [summary|verbose]; |
list backed up files | rman> list backupset by file; |
list backed up databases; | rman> list backup of database; |
list all datafile number 1 backups | rman> list backup of datafile 1; |
list backed up controlfiles | rman> list backup of controlfile; |
list backup scripts | rman> list script names; rman> list global script names; |
list all backups no longer required according to retention policy | rman> report obsolete; |
list all the physical datafiles | rman> report schema; |
list files that require backing up | rman> report need backup |
Useful Views |
|
v$controlfile_record_Section | displays information about the control file record sections |
v$backup_files | lists each file backed up, also has compressed option |
v$backup_set | lists backup sets |
v$backup_piece | lists backup pieces |
v$backup_redolog | lists archived backup logs |
v$backup_spfile | lists spfiles |
v$backup_device | names of SBT devices that have been linked to rman |
v$rman_configuration | lists all changed configurations settings (good point to check config) |
v$rman_status | Status of all completed rman jobs |
v$backup_corruption | provides important corruption information |
v$copy_corruption | provides important corruption information |
Deleting Backups
To removed old archive logs use "delete all" option, if all is missed only the archive logs in the primary destination will be deleted.
Examples | rman> delete backupset 12; Note: |
Catalog commands
The catalog command helps you identify and catalog any files that aren't recorded in RMAN's repository and thus are known to RMAN
catalog all data files copies | rman> catalog datafilecopy 'c:\oracle\backup\users01.dbf'; |
catalog all backup pieces copies | rman> catalog backuppiece ':c\oracle\backup\backup_20.bkp'; |
Search for uncatalog files in a directory | rman> catalog start with ':c\oracle\backup'; |
Delete discrepancy in catalog | rman> delete force noprompt archivelog sequence 40; |
Block change tracking
Block change tracking is used to backup very large databases,when you enable change block tracking a new process CTWR is then started:
Enabling | alter database enable block change tracking using file ‘c:\oracle\tracking\block_tracking.log’ |
Viewing | select filename, status, bytes from v$block_change_tracking; |
Disabling | alter database disable block change tracking; |