Refresh of PROD database using RMAN
Backup Prod database:
=======================
rman target /
host 'date';
run
{
sql "alter system archive log current";
sql "alter system switch logfile";
allocate channel d11 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d12 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d13 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d14 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d15 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d16 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d17 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d18 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d19 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d20 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d21 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d22 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d23 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d24 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d25 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d26 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d27 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d28 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d29 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d30 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d31 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d32 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d33 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d34 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d35 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d36 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
allocate channel d37 type disk format '/u01/EODDmp/PRODDB/RMAN/backup/Db_%d.%s.%p.%t.%T.bak';
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO 'DISK';
CONFIGURE DEVICE TYPE DISK PARALLELISM 25 BACKUP TYPE TO BACKUPSET;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
BACKUP SPFILE format '/u01/EODDmp/PRODDB/RMAN/backup/spfile_%d_%s_%T.bak';
backup as compressed BACKUPSET database ;
backup current controlfile format '/u01/EODDmp/PRODDB/RMAN/backup/control_%d_%s_%T.bak';
sql "alter system archive log current";
sql "alter system switch logfile";
backup as compressed BACKUPSET archivelog from time 'trunc(sysdate-1)' until time 'sysdate';
}
+++++++++++++++++++++++++++++++++++++++++++++++++++
Copy the files from PROD(source) to UAT/DEV(Target).
Example ==> from /u01/EODDmp/PRODDB/RMAN/backup/ to /u01/EODDmp/PRODDB/RMAN/backup
Restore command:
=============
Method-1:
=======
edit init file with below if we are using different location.
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initTEST.ora
*.db_create_file_dest='/u01/TEST/oradata'
*.db_file_name_convert='+DATA','/u01/TEST/oradata'
*.log_file_name_convert='+DATA','/u01/TEST/oradata'
*.db_recovery_file_dest='/u01/TEST/RMAN/backup'
then you have to create the directories depends on db_file_name_convert for restoration if its non ASM file system in UAT/DEV(Target).
As per above eg:
mkdir -p /u01/TEST/oradata/datafile
mkdir -p /u01/TEST/oradata/onlinelog
mkdir -p /u01/TEST/oradata/controlfile
mkdir -p /u01/TEST/oradata/tempfile
mkdir -p /u01/TEST/RMAN/backup
and start in nomount.
SQL> startup nomount pfile='/<path>/initTEST.ora';
rman auxiliary /
RMAN> DUPLICATE DATABASE TO 'TEST' BACKUP LOCATION '/u01/EODDmp/PRODDB/RMAN/backup';
If we use same file location. the we have to use.
RMAN> DUPLICATE DATABASE TO 'TEST' BACKUP LOCATION '/u01/EODDmp/PRODDB/RMAN/backup' NOFILENAMECHECK;
To change the database name:
=======================
change-
cp /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initTEST.ora /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initCLONE.ora
edit initCLONE.ora
*.db_name='CLONE'
*.db_unique_name='CLONE'
start in nomount.
rman auxiliary /
RMAN> DUPLICATE DATABASE TO 'CLONE' BACKUP LOCATION '/u01/EODDmp/PRODDB/RMAN/backup';
Method-2:
=======
RMAN> set dbid=3148849783
RMAN> startup force nomount;
RMAN> restore spfile from '/u01/EODDmp/PRODDB/RMAN/backup/spfile_TEST_49_20121011.bak';
shut immediate
startup nomount;
RMAN> restore controlfile from '/u01/EODDmp/PRODDB/RMAN/backup/control_TEST_54_20121011.bak';
RMAN> alter database mount;
--If the backup on target was different location then use RMAN > CATALOG START WITH '/backupdb/PRODDB/RMAN/backup/';
RMAN> restore database ;
RMAN> recover database;
RMAN> alter database open resetlogs;
No comments:
Post a Comment