Thursday, November 2, 2017
RMAN SCRIPT to format disk channel according to date
!/bin/bash -f
# - Variables -
#-----------------------------START
export ORACLE_HOME=/u02/app/oracle/product/11.2.0.4/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=MYDB4
export RMAN_LOG_NAME=Production_db_bkp_`date "+%d%m%Y"`.log
mkdir -p /u01/RMAN_BKP/dailyrmanbkp/`date "+%d%m%Y"`/db
mkdir -p /u01/RMAN_BKP/dailyrmanbkp/`date "+%d%m%Y"`/ar
mkdir -p /u01/RMAN_BKP/dailyrmanbkp/`date "+%d%m%Y"`/ctl
export DB_BACKUP_DIR=/u01/RMAN_BKP/dailyrmanbkp/`date "+%d%m%Y"`/db
export ARC_BACKUP_DIR=/u01/RMAN_BKP/dailyrmanbkp/`date "+%d%m%Y"`/ar
export CTL_BACKUP_DIR=/u01/RMAN_BKP/dailyrmanbkp/`date "+%d%m%Y"`/ctl
#-----------------------------END
rman target=sys/Password << EOF
SPOOL LOG to '/u01/RMAN_BKP/dailyrmanbkp/$RMAN_LOG_NAME';
run {
set controlfile autobackup format for device type disk to '${CTL_BACKUP_DIR}/cf_MYDB.%F';
allocate channel c1 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c2 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c3 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c4 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c5 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c6 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c7 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c8 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c9 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c10 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c11 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c12 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c13 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
allocate channel c14 device type disk format '${DB_BACKUP_DIR}/MYDB_DB_%u';
backup as compressed backupset SECTION SIZE 360000m database;
sql "alter system archive log current";
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
release channel c8;
release channel c9;
release channel c10;
release channel c11;
release channel c12;
release channel c13;
release channel c14;
allocate channel c1 device type disk format '${ARC_BACKUP_DIR}/MYDB_AR_%u';
allocate channel c2 device type disk format '${ARC_BACKUP_DIR}/MYDB_AR_%u';
allocate channel c3 device type disk format '${ARC_BACKUP_DIR}/MYDB_AR_%u';
allocate channel c4 device type disk format '${ARC_BACKUP_DIR}/MYDB_AR_%u';
backup
filesperset 4
AS COMPRESSED BACKUPSET archivelog all;
RELEASE CHANNEL ch1;
RELEASE CHANNEL ch2;
RELEASE CHANNEL ch3;
RELEASE CHANNEL ch4;
}
EOF
No comments:
Post a Comment