Thursday, March 7, 2013

Cold & Hot Disk Backup as compressed using RMAN:


Rman Disk Backup as compressed

$ rman target /

RMAN> show all;

using target database control file instead of recovery catalog

RMAN configuration parameters for database with db_unique_name HRPROD are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/oracle/prddb/db/tech_st/11.2.0.3/dbs/snapcf_prod.f'; # default

Steps to Cold Clone

$ rman target /

CONFIGURE CONTROLFILE AUTOBACKUP ON;  // default is off
run {
set controlfile autobackup format for device type 'sbt_tape' to '%F';  //For Tape backup
set controlfile autobackup format for device type disk to '/u01/dbcoldbkp/%F';
shutdown immediate
startup mount
allocate channel t1 device type disk;
backup as compressed backupset database format '/u01/dbcoldbkp /%d_%s_%p.dbf';
backup current controlfile format '/u01/dbcoldbkp /ctrl%d_%s_%p.ctl';
release channel t1;
}

Or

startup mount
$ rman target /
run{
   allocate channel dup1 device type disk;
   allocate channel dup2 device type disk;
   backup as compressed backupset format='/u01/dbcoldbkp /%U';
   release channel dup1;
   release channel dup2;
     }
Steps to Hot Clone

$ rman target /

run {
sql "alter system archive log current";
allocate channel t1 type disk;
allocate channel t2 type disk;
backup as compressed backupset format='/archivelogs/%U' database plus archivelog;
backup format='/archivelogs/Tp_cntl_%Y%M%D_%d_%s_%p.ctl' current controlfile;
release channel t1;
release channel t2;
}
+++++++++++++++++++++++++++++++++++++++

Rman hot backup :
 ++++++++++++++++++++++++++++++++++++++++++++
export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'

rman target /   << EOF
spool log to '$RMAN_LOG_FILE' append;
##CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CHANNEL DEVICE TYPE DISK clear;
CONFIGURE DEVICE TYPE DISK clear;

###############
## use these statements when backing up to DISK.
###############
##CONFIGURE DEVICE TYPE DISK PARALLELISM 10;
## If compression is enabled, add the following (not recommended for tape backups)
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' clear;
CONFIGURE DEVICE TYPE 'SBT_TAPE' clear;

CONFIGURE DEFAULT DEVICE TYPE TO DISK;
#CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DEVICE TYPE DISK;
CONFIGURE DEVICE TYPE DISK PARALLELISM 10 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_$SID_DT.bak';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/U01/BACKUP/$ORACLE_SID/CF_%F_$SID_DT.bak';

show all;
##scm#report schema;
sql 'alter system switch logfile';

## uncomment this line if using SPFILE to start DB
##backup FORMAT '/nfs/rman_db_backup/$ORACLE_SID/SPF_%t_%u_%s_%p_%I_$SID_DT.bak' SPFILE ;


sql 'alter system archive log current';
sql 'alter system switch logfile';
##backup FORMAT '/U01/BACKUP /$ORACLE_SID/AF_%e_%t_%u_%s_%p_beforebu_$SID_DT.bak' archivelog all filesperset 5 ;

## If compression is enabled, add the following (not recommended for tape backups)
##BACKUP AS COMPRESSED BACKUPSET ....

backup $BACKUP_TYPE FORMAT  '/U01/BACKUP /$ORACLE_SID/DF_%t_%u_%s_%p_%N_$SID_DT.bak' database filesperset 5 ;

#crosscheck archivelog all;
sql 'alter system archive log current';

backup FORMAT '/U01/BACKUP/$ORACLE_SID/AF_%e_%t_%u_%s_%p_afterbu_$SID_DT.bak' archivelog all filesperset 5 ;

sql 'alter system archive log current';
backup FORMAT '/U01/BACKUP/$ORACLE_SID/AF_%e_%t_%u_%s_%p_afterbu_$SID_DT.bak' archivelog all not backed up filesperset 5 ;
#backup FORMAT '/U01/BACKUP/$ORACLE_SID/Tp_cntrl_%e_%t_%u_%s_%p_afterbu_$SID_DT.bak' current controlfile;

##scm#list backup summary;
##scm#list backup;
sql 'alter database backup controlfile to trace';

spool log off;
quit;
EOF
++++++++++++++++++++++++++++
DB duplicate from Disk backup  :
++++++++++++++++++++++++++++
# shutdown the database
sqlplus / as sysdba << END_SQL1
shutdown abort
END_SQL1

cd $ORACLE_HOME/dbs
 mv * dbs_bak
 mv dbs_bak/initDEV.ora .
 mv dbs_bak/DEV_ebsdl1_ifile.ora .
rm /u01/oradata/DEV/*
rm /u02/oradata/DEV/*
# Get date and time of control file to use for duplicate database

for i in `ls -lt --time-style=+'%d-%b-%Y%H%M' /U01/BACKUP/QAT/CF_c*|awk  '{print $6 }'`
do
until_date=$i
echo 'until_date from the loop:  '${until_date}
done
 sqlplus / as sysdba << END_SQL2
startup nomount
END_SQL2
 export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'
# Start the duplicate database using RMAN

#rman 
#connect target sys/maner@QAT
#connect auxiliary /
#connect catalog rman4cata/cat4rman@grid
#RUN
Rman
connect auxiliary /
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;

set until time "to_date(upper('$until_date'),'DD-MON-YYYYHH24MI')+(1/24/60)";

DUPLICATE DATABASE TO DRTSTC BACKUP LOCATION '/U01/BACKUP/QAT/' NOFILENAMECHECK
DB_FILE_NAME_CONVERT=('QAT','DEV')
LOGFILE
  GROUP 1 (
    '/u01/oradata/DEV/log01a.redo',
    '/u02/oradata/DEV/log01b.redo'
  ) SIZE 200M ,
  GROUP 2 (
    '/u01/oradata/DEV/log02a.redo',
    '/u02/oradata/DEV/log02b.redo'
  ) SIZE 200M ,
  GROUP 3 (
    '/u01/oradata/DEV/log03a.redo',
    '/u02/oradata/DEV/log03b.redo'
  ) SIZE 200M ;

RELEASE CHANNEL disk1;
RELEASE CHANNEL disk2;
RELEASE CHANNEL disk3;
RELEASE CHANNEL disk4;
RELEASE CHANNEL disk5;
}
exit
END_RMAN
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

221779.1 ,397315.1,1077022.1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

No comments:

Post a Comment