Hungry DBA .com for DBAs who like food
 

Example of how to perform Oracle 10g RMAN backup and recovery 

-- Launch rman from the command line 

C:\>rman target / 

-- Check the RMAN configuration

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'E:\oracle\ORABACKUP\rman\backups\UAT\CONTROLFILE_%d_%F';
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 3;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT 'E:\oracle\ORABACKUP\rman\backups\UAT\%U' MAXPIECESIZE 2000 M;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 'E:\oracle\ORABACKUP\rman\backups\UAT\%U' MAXPIECESIZE 2000 M;
CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT 'E:\oracle\ORABACKUP\rman\backups\UAT\%U' MAXPIECESIZE 2000 M;
CONFIGURE MAXSETSIZE TO UNLIMITED;
CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE ENCRYPTION ALGORITHM 'AES128';
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:\ORACLE\10.2.0\DB_1\DATABASE\SNCFUAT.ORA'; # default

-- To make changes just issue the relevant above commands with the appropriate change; for example the below changes the retention policy to a recovery window of 15 days:

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 15 DAYS;

old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 15 DAYS;
new RMAN configuration parameters are successfully stored
 

-- Checking the configuration again shows that the recovery window is now set to 15 days:

RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 15 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'E:\oracle\ORABACKUP\rman\backups\UAT\CONTROLFILE_%d_%F';
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 3;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT 'E:\oracle\ORABACKUP\rman\backups\UAT\%U' MAXPIECESIZE 2000 M;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 'E:\oracle\ORABACKUP\rman\backups\UAT\%U' MAXPIECESIZE 2000 M;
CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT 'E:\oracle\ORABACKUP\rman\backups\UAT\%U' MAXPIECESIZE 2000 M;
CONFIGURE MAXSETSIZE TO UNLIMITED;
CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE ENCRYPTION ALGORITHM 'AES128';
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:\ORACLE\10.2.0\DB_1\DATABASE\SNCFUAT.ORA'; # default

-- The below will backup the database and archive logs; will delete the original archive logs that were backed up by this command; delete old backups beyond the abover retention policy recovery window (e.g. older than 15 days); and verify that all required backups needed for recovery are in place:

RMAN> run 

    {
     BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
     DELETE NOPROMPT OBSOLETE;
     CROSSCHECK BACKUP;
    }

-- The below command will backup archive logs and delete the originals that were backed up:

RMAN> backup archivelog all delete input;

-- The below command verifies that all required backups needed for recovery are in place:

RMAN> crosscheck backup;

-- The below will perform a full recovery:

RMAN> shutdown immediate;
RMAN> startup mount;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open;

-- The below will recover a specific tablespace; the datafile must be taken off line first if the database is up:

RMAN> restore tablespace users;

RMAN> recover tablespace users; 

-- The below will recover a specific datafile; must be taken offline first if the database is up: 

RMAN> restore datafile 'D:\oradata\UAT\users_01.dbf';

RMAN> recover datafile 'D:\oradata\UAT\users_01.dbf';

-- The below will perform point in time recovery:

run {
shutdown immediate;
startup mount;
set until time 'APR 15 2007 09:00:00';
# set until scn 1000; # alternatively, you can specify SCN -- 1000 will restore up to 999
# set until sequence 1234; # alternatively, you can specify log sequence number -- 1234 will restore up to 1233

restore database;
recover database;
alter database open resetlogs;
}