Wednesday, April 24, 2013

DB Duplicate From PROD To TEST:



DB Duplicate From PROD To TEST:
=========================
 Step 1:
Create password file on PROD , then copy same file to TEST

orapwd file=orapw$ORACLE_SID password=welcome

Step 2:
Prod db should be archive log mode…

Step 3:
Before firing disk backup script, check the backup location is available or not -à /BACKUP/rman_db_backup/PROD

[oracle@prodebsdl1 scripts]$ cat rman_hot_backup_disk.sh
rman target /

spool log to '/home/oracle/rman_db_backup/logs/PROD_disk_hot_backup.log' append;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE DEVICE TYPE DISK PARALLELISM 5 BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE MAXSETSIZE TO UNLIMITED;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'CF_snapshot_PROD_May06.bak';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/BACKUP/rman_db_backup/PROD/CF_%F_PROD_May06.bak';


Run{

sql 'alter system archive log current';
sql 'alter system switch logfile';

backup FORMAT  '/BACKUP/rman_db_backup/PROD/DF_%t_%u_%s_%p_%N_HRPROD_May06.bak' database;

sql 'alter system archive log current';

backup FORMAT '/BACKUP/rman_db_backup/PROD/AF_%e_%t_%u_%s_%p_afterbu_PROD_May06.bak' archivelog all;

sql 'alter system archive log current';

backup FORMAT '/BACKUP/rman_db_backup/PROD/AF_%e_%t_%u_%s_%p_afterbu_PROD_May06.bak' archivelog all not backed up;

sql 'alter database backup controlfile to trace';
}
spool log off;
quit;
EOF

TESTDB:

Step 1:
Please check backup location is mounted,
Step:
Remove all the datafiles
Step3:

DB should be  nomont
# Start the instance for duplicate database
sqlplus / as sysdba << END_SQL
startup nomount
END_SQL
Step 4: Connect to Target
rman target sys/welcome@PROD auxiliary /

Step 5:
Run the bellow script on Rman prompt

[oracle@devebsdl1 scripts]$ cat TEST.sql
RUN
{
ALLOCATE AUXILIARY CHANNEL disk1 DEVICE TYPE disk;
ALLOCATE AUXILIARY CHANNEL disk2 DEVICE TYPE disk;
ALLOCATE AUXILIARY CHANNEL disk3 DEVICE TYPE disk;
ALLOCATE AUXILIARY CHANNEL disk4 DEVICE TYPE disk;
ALLOCATE AUXILIARY CHANNEL disk5 DEVICE TYPE disk;
ALLOCATE AUXILIARY CHANNEL disk6 DEVICE TYPE disk;
DUPLICATE DATABASE TO HRTST BACKUP LOCATION '/BACKUP/rman_db_backup/PROD/' NOFILENAMECHECK
DB_FILE_NAME_CONVERT=('PROD','TEST')
LOGFILE
  GROUP 1 (
    '/u01/oracle/TEST/db/apps_st/data/log01a.dbf',
    '/u01/oracle/TEST/db/apps_st/data/log01b.dbf'
  ) SIZE 1000M,
  GROUP 2 (
    '/u01/oracle/TEST/db/apps_st/data/log02a.dbf',
    '/u01/oracle/TEST/db/apps_st/data/log02b.dbf'
  ) SIZE 1000M;

RELEASE CHANNEL disk1;
RELEASE CHANNEL disk2;
RELEASE CHANNEL disk3;
RELEASE CHANNEL disk4;
RELEASE CHANNEL disk5;
RELEASE CHANNEL disk6;
}

++++++++++++++++++++++++++++++++++++++++++++++


No comments:

Post a Comment