Example of how to perform RMAN backup and recovery
Before Using RMAN you must know about RMAN concept ...
http://www.dba-oracle.com/concepts/rman.htm
http://www.oraclecoursebooks.com/books/oracle10g_rman/oracle10g_rman.html
Starting RMAN Utility
C:\>rman target /
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 above commands with the desired value;
e.g the retention policy
to a recovery window of 12 days:
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 12 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 12 DAYS;
new RMAN configuration parameters are successfully stored
-- Checking the configuration again shows that the recovery window is now set to 12 days:
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 12 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 above retention policy recovery window (e.g. older
than 12 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;
}
Command to backup archive logs and delete the originals that were backedup before:
RMAN> backup archivelog all delete input;
Command to verifies that all required backups needed for recovery are in place:
RMAN> crosscheck backup;
Perform a full recovery:
RMAN> shutdown immediate;
RMAN> startup mount;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open;
Command to 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;
Command to 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';
Command to 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;
}
No comments:
Post a Comment