Tuesday, June 17, 2014

Example RMAN Script

RUN {


ALLOCATE CHANNEL ch00 TYPE 'DISK';
BACKUP
    TAG CONTROLFILE_BACKUP
    FORMAT '/u02/rman_backup/cntrl_%s_%p_%t'
    CURRENT CONTROLFILE;
RELEASE CHANNEL ch00;

ALLOCATE CHANNEL ch00 TYPE DISK;
ALLOCATE CHANNEL ch01 TYPE DISK;
ALLOCATE CHANNEL ch02 TYPE DISK;
ALLOCATE CHANNEL ch03 TYPE DISK;

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

BACKUP
    TAG MEIS_DB_BACKUP
    FORMAT '/u02/rman_backup/MEIS_%s_%p_%t'
    DATABASE;
   

RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;


ALLOCATE CHANNEL ch00 TYPE 'DISK';
ALLOCATE CHANNEL ch01 TYPE 'DISK';

BACKUP
   TAG ARCHIVELOG_BACKUP
   FORMAT '/u02/rman_backup/arc_MEIS_%s_%p_%t'
   ARCHIVELOG ALL DELETE INPUT;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;



}

EXP: Shell Script

==========================================================

#!/bin/bash
cd
. .bash_profile
export BACKUPPATH="path_to_backup_file"

for i in DB1 DB2
do
export DATAFILE="${i}_DATAFILE_$(date '+%Y%m%d')"
echo $DATAFILE
export ARCHIVEDLOG="${i}_ARCHIVEDLOG_$(date '+%Y%m%d')"
echo $ARCHIVEDLOG
export CONTROLFILE="${i}_CONTROLFILE_$(date '+%Y%m%d')"
echo $CONTROLFILE
export RMAN_LOG_FILE="RMAN_FULL_BACKUP_${i}_$(date '+%Y%m%d').out"
echo $RMAN_LOG_FILE
echo Backup_data_file_path=$BACKUPPATH

export ORACLE_SID=$i
rman target / msglog ${BACKUPPATH}/log/$RMAN_LOG_FILE <<EOF
run
{
ALLOCATE CHANNEL ch00 TYPE DISK;
ALLOCATE CHANNEL ch01 TYPE DISK;
ALLOCATE CHANNEL ch02 TYPE DISK;
ALLOCATE CHANNEL ch03 TYPE DISK;

BACKUP
    TAG "${DATAFILE}"
    FORMAT '${BACKUPPATH}/${i}/DATA_${i}_%s_%p_%t'
    DATABASE;
    sql 'alter system archive log current';
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;

ALLOCATE CHANNEL ch00 TYPE DISK;
ALLOCATE CHANNEL ch01 TYPE DISK;

BACKUP
   TAG "${ARCHIVEDLOG}"
   FORMAT '${BACKUPPATH}/${i}/arc_${i}_%s_%p_%t'
   ARCHIVELOG ALL DELETE INPUT;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;

ALLOCATE CHANNEL ch00 TYPE DISK;
BACKUP
    TAG "${CONTROLFILE}"
    FORMAT '${BACKUPPATH}/${i}/cntrl_${i}_%s_%p_%t'
    CURRENT CONTROLFILE;
RELEASE CHANNEL ch00;
}
CROSSCHECK BACKUP;
DELETE NOPROMPT OBSOLETE;
EXIT;
EOF
echo $i
done


tip: SCN

Controlfile----> Datafile----> Archivelog

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

ALCATEL 6900

write memory copy running certified reload from working no rollback-timeout