An RMAN script can pull of these configurations together and automate the backup job. The following is an instructional script that shows how these components work together.
This gives a basic script for a starting point to understanding the RMAN recommendations and be able to implement them. There is also a good chance that a script has already been configured for your environment, and this will help in understanding it.
Check for Corruption
A backup file is only good if you can restore it. You can use RMAN to check for corruption in data files, archivelogs, and control files.
You can also verify whether a backup set is restorable. The RMAN VALIDATE command is used to perform these types of integrity checks.
There are three ways you can run the VALIDATE command:
• VALIDATE
• BACKUP … VALIDATE
• RESTORE … VALIDATE
The VALIDATE command can be used on its own to check for missing files or physical corruption in database data files, archivelog files, control files, spfiles, and backup set pieces. For example, this command will validate all data files and the control files:
RMAN> validate database;
You can also validate just the control file, as follows:
RMAN> validate current controlfile;
You can validate the archivelog files, like so:
RMAN> validate archivelog all;
You may want to combine all the prior integrity checks into one command, as shown here:
RMAN> validate database include current controlfile plus archivelog;
Under normal conditions, the VALIDATE command checks only for physical corruption. You can specify that you also want to check for logical corruption by using the CHECK LOGICAL clause:
RMAN> validate check logical database include current controlfile plus archivelog;
VALIDATE has a variety of uses. Here are a few more examples:
RMAN> validate database skip offline; RMAN> validate copy of database; RMAN> validate tablespace system; RMAN> validate datafile 3 block 20 to 30; RMAN> validate spfile; RMAN> validate backupset <primary_key_value>; RMAN> validate recovery area;RMAN> validate pluggable database pdbname;
If RMAN detects any corrupt blocks, the V$DATABASE_BLOCK_CORRUPTION is populated. This view contains information on the file number, block number, and number of blocks affected. You can use this information to perform a block-level recovery.
Physical corruption is a change to a block, such that its contents do not match the physical format that Oracle expects. By default, RMAN checks for physical corruption when backing up, restoring, and validating data files. With logical corruption, a block is in the correct format, but the contents are not consistent with what Oracle expects, such as in a row piece or an index entry.