Thursday, February 26, 2009

RMAN Backups - Configure/Backup/Report Commands

Persistant Configuration
CONFIGURE command enables you to configure various backup, restore and recover parameters

Retention Policy
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
Establishes the number of backups files and control files you want to retain

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
Establishes the number of days the backups are to be retained. The redundancy policy and the recovery window policy are mutually exclusive

Automatic Channel Configuration and Allocation
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'd:\backups\bkup_%d_%s_%p';
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE DEFAULT DEVICE TYPE CLEAR;

Automatic Backup of Control Files
BACKUP command INCLUDING CONTROL FILE;

Backup Optimization
CONFIGURE BACKUP OPTIMIZATION ON;
Will cause Oracle to skip backups of files that already have identical backups on the device being backed up to.
if it is ON, RMAN skips the files for which a backup already exists on the same device with the same header status. The same header implies that no modifications where made to the data in those files since the last backup. This feature is useful for archivelog backups; in this case the archivelog files that are already backed up can be skipped

Automated Backups of the Control File and the Database Parameter File
configure controlfile autobackup on;
configure controlfile autobackup off;
When autobackup of the control and parameter files is configured, the following rule apply:
> The control file and the server parameter file will be automatically backed up with each RMAN backup or copy command issued that is not included in a run block.
> If a run block is used, the control files and parameter files will be backed up at the end of the run block if the last command is not backup or copy.
RMAN> configure controlfile autobackup format for device type disk to 'd:\backup\contf\robt_%F'
When this option is used, the Oracle RDBMS will automatically back up the control file during database structure changes that impact the control file.

Number of channels
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT 'd:\backup\robt\backup_%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 'e:\backup\robt\backup_%U';
If you start an automated backup, two channels will be allocated to perform the backup in parallel.

Excluding Tablespaces
CONFIGURE EXCLUDE FOR TABLESPACE hr_tbsp;
CONFIGURE EXCLUDE FOR TABLESPACE hr_tbsp clear;

Size of backup set piece
CONFIGURE CHANNEL 1 DEVICE TYPE DISK MAXPIECESIZE 100m;
We are limiting channel 1 to create each individual backup piece at a maximum size of 100mb. Note that this command does not limit the overall size of the backup.

MaxSize for entire backup set
CONFIGURE MAXSETSIZE TO 7500K;
CONFIGURE MAXSETSIZE CLEAR;
Duplexed copies
configure datafile backup copies for device type disk to 2;

Snapshot control file
configure snapshot control file name to 'd:\oracle\backup\scontrolf';
This file is a point-in-time copy of the database control file that is taken during RMAN backup operations. This ensures that the backup is consistent to a given point in time.Thus, if you add a tablespace or datafile to a database after the backup has started(assuming an online backup, of course) that tablespace or datafile will not be included in the backup Backup Commands Options

Backup of Archive logs
BACKUP DATABASE PLUS ARCHIVELOG;

Restartable Backups
BACKUP DATABASE NOT BACKED UP SINCE TIME 'sysdate - 7';
Tags - Each backup in Oracle can be assigned a tag
RMAN> backup database tag = 'test backup'

Limiting the size of a Backup Set
RMAN> backup database maxsetsize=50m tag='test backup'

Using this parameter we have limited the maximum size of the backup set to 50MB. This is handy if your tape has a size limit or if your disks can only handle datafiles that are a certain size.

Modifying the Retention Policy for a Backup Set
backup database keep forever;
backup database keep until time ='sysdate+180';

Overriding the configure exclude command
backup database noexclude keep forever tag='test backup';
If you want to ensure that RMAN back up these datafiles, you can include the noexclude parameter in the backup command.

Checking the Database for Errors with Backup Command
backup validate database;
Scan the database for physical and logical errors without actually doing a
backup.
Skipping offline, Inaccessible or Read-Only Datafiles
backup database skip readonly;
backup database skip offline;
backup database skip inaccessible;
backup database skip readonly skip offline skip inaccessible;

Forcing a Backup of Read only Datafiles
backup database force;
Backing Up Datafiles Based on Their Last Backup Time

Backing up only newly added datafiles
backup database not backed up;

Backing up files not backed up in a specific time period
backup database not backed up sice time='sysdate -2';

Checking for logical corruption during a backup
backup check logical database;
backup validate check logical database;

If you wish the backup to continue through a given number of errors, you need to set the maxcorrupt parameter first. This requires using a run block, as shown in this example
run{
set maxcorrupt for datafile 1,2,3,4,5,6,7 to 10;
backup validate check logical database;
}

Making copies of Backups on our RMAN copier
backup database copies=2;

Capturing the Elusive Control File
backup database device type disk include current controlfile;
Set Command Options
To define settings that only apply to the current RMAN session.
> To Display RMAN commands inthe message log, use the set echo command
> To specify a database's database identified (DBID), use the set DBID command
Certain set commands can only be used within the confines of a run block.
- The set newname command is useful if you are performing TSPITR or database duplication The set newname command allows you to specify new database datafile names This is useful if you are moving the database to a new system and the file system names are different. You need to use the switch command in combination with the set newname command.
- Using the set maxcorrupt for datafile command enables you to define a maximum number of data block corruptions allowed before the RMAN operation will fail
- Using the set archivelog destination command allows you to modify the archive_log_Dest_1 destination for archived redo logs
- Using the set with the until clause of the set command enables you to define a specific poing in time, an SCN, or a log sequence number, to be used during database point-in-time recovery
- using the set backup copies command enables you to define how many copies of the backup files should be created for each backup piece in the backup set
- Using the set command id setting enables you to associate a given server session to a given channel
- Using the set controlfile autobackup format for device type command enables you to modify the default format for control file autobackups.
run
{
set maxcorrupt for datafile 3 to 10;
set backup copies = 3;
backup database;
}
If you wish to do a backup that creates two copies of each backup piece that is created, an you want to allow for ten corruptions in datafile 3.

Report Commands
REPORT OBSOLETE RECOVERY WINDOWS 7 DAYS;
REPORT NEED BACKUP RECOVERY WINDOW 7 DAYS;

LIST Commands

LIST BACKUP
LIST BACKUP BY FILE;

Other Commands
SHOW ALL;
SHOW RETENTION POLICY;

CROSSCHECK
command to check if backup sets or file copies exist

3 comments:

Unknown said...

Very well written.

Mirza said...

Very Good Bro...

JazakAllah


--
Mirza

DBAUniv said...

Salam Brother,

JazakAllah U have done really nice job.. I got new things

Thanks a lot for sharing your valuable knowledge.


Wasim Mohammad