$more ~/bin/pkg/rman_backup/body.sh
#!/bin/bash
#
# Check Parameters:
#
# Package Name:
tmp_string="`dirname $0`"
pkg_name="`basename ${tmp_string}`"
if [ "${pkg_name}" = "." ]; then
tmp_string="`pwd`"
pkg_name="`basename ${tmp_string}`"
fi
# Check for internal call:
if [ ! $1 = '_run' ]; then
echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=1) Call `basename $0` from ./_run.sh" >&2
exit 2
fi
# Check For:
if [ $2 ]
then
echo " 2=${2} (ORACLE_SID)"
ORACLE_SID=`echo ${2} | tr "[A-Z]" "[a-z]"`; export ORACLE_SID
else
echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=2) Call `basename $0` With 2-d parameter" >&2
exit 2
fi
#
# Define local variables:
#
# Variables:
prefix="${COMPANY_NAME}#${HOST_NAME}(${ORACLE_SID}) ${pkg_name}"
mess_theme="${prefix}:Rman backup"
log_file=${TMP_DIR}/${pkg_name}_${ORACLE_SID}.log
mail_recipients="$MAIL_DBA"
echo $mail_recipients
start_secs=$(/usr/xpg4/bin/awk 'BEGIN{srand();print srand()}')
begin_backup="`date +%Y.%m.%d" "%H:%M:%S`"
sqlplus '/ as sysdba' << EOF > /dev/null
alter database backup controlfile to trace as '$RMAN_BKP/$ORACLE_SID/oradata/ctrl_trace_${ORACLE_SID}' reuse;
create pfile='$RMAN_BKP/$ORACLE_SID/oradata/init${ORACLE_SID}.bkp' from spfile;
exit;
EOF
$UTL_RMAN target / catalog 'rman/pwd@catdb.sun.com' cmdfile ${BIN_DIR}/_sql/backup.rman log=${log_file}
finish_secs=$(/usr/xpg4/bin/awk 'BEGIN{srand();print srand()}')
end_backup="`date +%Y.%m.%d" "%H:%M:%S`"
let diff_secs=($finish_secs - $start_secs)
let days=$diff_secs/86400
let remainder=$diff_secs%86400
let hours=$remainder/3600
let remainder=$remainder%3600
let minutes=$remainder/60
let seconds=$remainder%60
size=$(du -sh /u09/backups/oradb/rman/testdb/oradata/ | awk '{print $1}')
echo "Begin backup: $begin_backup" >> ${log_file}
echo "End backup: $end_backup" >> ${log_file}
echo "Duration: Days = $days, Hours = $hours, Minutes = $minutes, Seconds = $seconds" >>${log_file}
echo "Size: $size" >>${log_file}
cat ${log_file} | ${BIN_DIR}/_lib/utl_send.sh "${mess_theme}" "${mail_recipients}"
$
$more ~/bin/_sql/backup.rman
# Clear Parameters:
CONFIGURE RETENTION POLICY CLEAR;
CONFIGURE BACKUP OPTIMIZATION CLEAR;
CONFIGURE DEFAULT DEVICE TYPE CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT CLEAR;
CONFIGURE DEVICE TYPE DISK CLEAR;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT CLEAR;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT CLEAR;
CONFIGURE ARCHIVELOG DELETION POLICY CLEAR;
CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR;
CONFIGURE CHANNEL DEVICE TYPE SBT CLEAR;
CONFIGURE MAXSETSIZE CLEAR;
CONFIGURE SNAPSHOT CONTROLFILE NAME CLEAR;
CONFIGURE ENCRYPTION FOR DATABASE CLEAR;
CONFIGURE ENCRYPTION ALGORITHM CLEAR;
CONFIGURE COMPRESSION ALGORITHM CLEAR;
CONFIGURE DB_UNIQUE_NAME TESTDB_P CLEAR;
CONFIGURE DB_UNIQUE_NAME TESTDB_S CLEAR;
# Configure Parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$RMAN_BKP/$ORACLE_SID/oradata/%d-%F';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '$RMAN_BKP/$ORACLE_SID/oradata/db_%d_%s_%p_%t';
CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET;
CONFIGURE DB_UNIQUE_NAME TESTDB_P CONNECT IDENTIFIER 'testdb_p.sun.com';
CONFIGURE DB_UNIQUE_NAME TESTDB_S CONNECT IDENTIFIER 'testdb_s.sun.com';
#CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY FOR DB_UNIQUE_NAME TESTDB_P; # For Catalog Only
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY FOR DB_UNIQUE_NAME TESTDB_S; # For Catalog Only
show all;
crosscheck backup;
crosscheck copy;
crosscheck archivelog all;
CROSSCHECK BACKUP OF CONTROLFILE;
CROSSCHECK BACKUP OF SPFILE;
delete noprompt expired backup;
delete noprompt expired copy;
delete noprompt expired archivelog all;
run
{
backup incremental level 1 for recover of copy with tag 'incr_backup_testdb' database;
recover copy of database with tag 'incr_backup_testdb';
}
run
{
backup archivelog all not backed up;
}
run
{
crosscheck backup;
crosscheck copy;
delete noprompt expired backup;
delete noprompt expired copy;
delete noprompt obsolete;
}
backup current controlfile for standby tag 'standby controlfile';
report schema;
list copy;
list backup;
list backup summary;
$
#!/bin/bash
#
# Check Parameters:
#
# Package Name:
tmp_string="`dirname $0`"
pkg_name="`basename ${tmp_string}`"
if [ "${pkg_name}" = "." ]; then
tmp_string="`pwd`"
pkg_name="`basename ${tmp_string}`"
fi
# Check for internal call:
if [ ! $1 = '_run' ]; then
echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=1) Call `basename $0` from ./_run.sh" >&2
exit 2
fi
# Check For
if [ $2 ]
then
echo " 2=${2} (ORACLE_SID)"
ORACLE_SID=`echo ${2} | tr "[A-Z]" "[a-z]"`; export ORACLE_SID
else
echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=2) Call `basename $0` With 2-d parameter" >&2
exit 2
fi
#
# Define local variables:
#
# Variables:
prefix="${COMPANY_NAME}#${HOST_NAME}(${ORACLE_SID}) ${pkg_name}"
mess_theme="${prefix}:Rman backup"
log_file=${TMP_DIR}/${pkg_name}_${ORACLE_SID}.log
mail_recipients="$MAIL_DBA"
echo $mail_recipients
start_secs=$(/usr/xpg4/bin/awk 'BEGIN{srand();print srand()}')
begin_backup="`date +%Y.%m.%d" "%H:%M:%S`"
sqlplus '/ as sysdba' << EOF > /dev/null
alter database backup controlfile to trace as '$RMAN_BKP/$ORACLE_SID/oradata/ctrl_trace_${ORACLE_SID}' reuse;
create pfile='$RMAN_BKP/$ORACLE_SID/oradata/init${ORACLE_SID}.bkp' from spfile;
exit;
EOF
$UTL_RMAN target / catalog 'rman/pwd@catdb.sun.com' cmdfile ${BIN_DIR}/_sql/backup.rman log=${log_file}
finish_secs=$(/usr/xpg4/bin/awk 'BEGIN{srand();print srand()}')
end_backup="`date +%Y.%m.%d" "%H:%M:%S`"
let diff_secs=($finish_secs - $start_secs)
let days=$diff_secs/86400
let remainder=$diff_secs%86400
let hours=$remainder/3600
let remainder=$remainder%3600
let minutes=$remainder/60
let seconds=$remainder%60
size=$(du -sh /u09/backups/oradb/rman/testdb/oradata/ | awk '{print $1}')
echo "Begin backup: $begin_backup" >> ${log_file}
echo "End backup: $end_backup" >> ${log_file}
echo "Duration: Days = $days, Hours = $hours, Minutes = $minutes, Seconds = $seconds" >>${log_file}
echo "Size: $size" >>${log_file}
cat ${log_file} | ${BIN_DIR}/_lib/utl_send.sh "${mess_theme}" "${mail_recipients}"
$
$more ~/bin/_sql/backup.rman
# Clear Parameters:
CONFIGURE RETENTION POLICY CLEAR;
CONFIGURE BACKUP OPTIMIZATION CLEAR;
CONFIGURE DEFAULT DEVICE TYPE CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT CLEAR;
CONFIGURE DEVICE TYPE DISK CLEAR;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT CLEAR;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT CLEAR;
CONFIGURE ARCHIVELOG DELETION POLICY CLEAR;
CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR;
CONFIGURE CHANNEL DEVICE TYPE SBT CLEAR;
CONFIGURE MAXSETSIZE CLEAR;
CONFIGURE SNAPSHOT CONTROLFILE NAME CLEAR;
CONFIGURE ENCRYPTION FOR DATABASE CLEAR;
CONFIGURE ENCRYPTION ALGORITHM CLEAR;
CONFIGURE COMPRESSION ALGORITHM CLEAR;
CONFIGURE DB_UNIQUE_NAME TESTDB_P CLEAR;
CONFIGURE DB_UNIQUE_NAME TESTDB_S CLEAR;
# Configure Parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$RMAN_BKP/$ORACLE_SID/oradata/%d-%F';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '$RMAN_BKP/$ORACLE_SID/oradata/db_%d_%s_%p_%t';
CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET;
CONFIGURE DB_UNIQUE_NAME TESTDB_P CONNECT IDENTIFIER 'testdb_p.sun.com';
CONFIGURE DB_UNIQUE_NAME TESTDB_S CONNECT IDENTIFIER 'testdb_s.sun.com';
#CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY FOR DB_UNIQUE_NAME TESTDB_P; # For Catalog Only
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY FOR DB_UNIQUE_NAME TESTDB_S; # For Catalog Only
show all;
crosscheck backup;
crosscheck copy;
crosscheck archivelog all;
CROSSCHECK BACKUP OF CONTROLFILE;
CROSSCHECK BACKUP OF SPFILE;
delete noprompt expired backup;
delete noprompt expired copy;
delete noprompt expired archivelog all;
run
{
backup incremental level 1 for recover of copy with tag 'incr_backup_testdb' database;
recover copy of database with tag 'incr_backup_testdb';
}
run
{
backup archivelog all not backed up;
}
run
{
crosscheck backup;
crosscheck copy;
delete noprompt expired backup;
delete noprompt expired copy;
delete noprompt obsolete;
}
backup current controlfile for standby tag 'standby controlfile';
report schema;
list copy;
list backup;
list backup summary;
$
Комментариев нет:
Отправить комментарий