Skip to content

Commit

Permalink
adding check_best_practices and crosscheck fix
Browse files Browse the repository at this point in the history
1. adding check_best_practices
2. crosscheck fix - check only X latest days - crosscheck maybe
extremely slow with commvault and maybe other backup solutions.
  • Loading branch information
Tagar committed Jul 16, 2014
1 parent 459c46c commit 0023cb9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
11 changes: 6 additions & 5 deletions rman_backup.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ EOF
}
#-------------------------------------------
function DO_RMAN_BACKUP {
renice_rman &
renice_pid=$!

p=$BACKUP_PARALLELISM
case $MODE in
ARCH) backup_archive_logs
Expand All @@ -133,6 +130,9 @@ $SCRIPT
$RMAN_TRAIL_SCRIPT $RMAN_RELEASE_CHANNELS
}
"
renice_rman &
renice_pid=$!

run_the_script

kill $renice_pid >/dev/null 2>&1
Expand All @@ -157,10 +157,10 @@ function DO_BACKUP_CROSSCHECK {
SCRIPT="$RMAN_INIT
$RMAN_CHANNELS
#-- Run crosschecks and then report backup pieces and archived logs found as missing.
CROSSCHECK BACKUP;
CROSSCHECK BACKUP completed after 'SYSDATE-$RECOVERY_WINDOW-5';
LIST EXPIRED BACKUP;
CROSSCHECK ARCHIVELOG ALL;
CROSSCHECK ARCHIVELOG ALL completed after 'SYSDATE–$RECOVERY_WINDOW-5';
LIST EXPIRED ARCHIVELOG ALL;
#-- Report what's affected by certain NOLOGGING operations and can't be recovered
Expand Down Expand Up @@ -245,6 +245,7 @@ do
{ echo "===== Starting $MODE for $db @ `date`...."
reset_global_vars
get_database_info
check_best_practices

if [ "x$DG" = 'xDG' ]; then
#for DG databases we should connect using TNS (not just target=/), see Doc ID 1604302.1
Expand Down
24 changes: 19 additions & 5 deletions rman_backup.ksh.subs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ end;
echo "INFO: $used_mb"
}

function check_best_practices {
dosql ctlf_record_keep_time "select value from v\$parameter where name='control_file_record_keep_time'"
if [ "$ctlf_record_keep_time" -lt $(( $RECOVERY_WINDOW +10 )) ] ; then
echo "WARN: CONTROL_FILE_RECORD_KEEP_TIME init parameter is $ctlf_record_keep_time is too low."
echo "WARN: Recommended value is $(( $RECOVERY_WINDOW +10 )) based on your recovery window and Oracle Note 829755.1."
if [ "$FIX_BEST_PRACTICES" -eq "1" ] ; then
dosql noreturn "ALTER SYSTEM SET CONTROL_FILE_RECORD_KEEP_TIME=$(( $RECOVERY_WINDOW +10 )) scope=BOTH"
echo "WARN: Fixed!"
fi
fi
}


#-------------------------------------------

function check_FRA {
Expand Down Expand Up @@ -297,9 +310,10 @@ function remove_old_files {
find $BASE_PATH/log \( -mtime +65 -name "rmanbackup*.log" \
-o -mtime +4 -name "rmanbackup*.rman-trace" \
\) -print -exec rm {} \;
find $BASE_PATH/scripts \( -name "rmanclone_*.sh" \
-o -name "*.*-bkpcopy" \
\) -mtime +65 -print -exec rm {} \;
find $BASE_PATH/scripts \( -mtime +65 -name "rmanclone_*.sh" \
-o -mtime +35 -name "controlf-*.ctl-bkpcopy" \
-o -mtime +65 -name "*.*-bkpcopy" \
\) -print -exec rm {} \;
}

#-------------------------------------------
Expand Down Expand Up @@ -451,10 +465,10 @@ function rman_pri_configures {

function reset_global_vars {
unset DB_ROLE SCRIPT RMAN_CHANNELS RMAN_RELEASE_CHANNELS PIDS CH_FORMAT
unset CLONE_DATANAMES CLONE_TEMPNAMES CLONE_LOGNAMES handle
unset CLONE_DATANAMES CLONE_TEMPNAMES CLONE_LOGNAMES handle ctlf_record_keep_time
unset compressed Ver10up Release FRA_PRC_USED_SOFT FRA_PRC_USED_HARD FRA_THRESHOLD pridb
unset p c lines S1 S2 params minutes seconds errcount rman_debug clone_script dt
#Global variables not to clean: DG
#Global variables not to clean (they don't change from a database to database): DG
#
PATH=$orig_PATH:$PATHS
MODE=$orig_MODE
Expand Down
5 changes: 3 additions & 2 deletions rman_backup.ksh.vars
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CUMULATIVE=1 #one of: 0 or 1 (to use CUMULATIVE incremental backups)
BACKUP_PARALLELISM=2 #number of channels / parallelism
RECOVERY_WINDOW=35 #in days (at least one full business cycle +a few days if space allows)
DBA_EMAIL="[email protected]" #where to send notifications and errors
FIX_BEST_PRACTICES=1 #if 1, then will fix best practices automatically
BACKUP_DEBUG=0 #one of: 0 or 1 (backup script debug)

#------------------------------------------------------------------
Expand Down Expand Up @@ -132,8 +133,8 @@ fi

#platform-specific renice/nice commands:
case `uname` in
Linux) RENICE="renice +$NICE" ;;
*) RENICE="renice -n $NICE" ;;
Linux) RENICE="renice +$NICE" ;; #in Linux renice sets nice priority to absolute value,
*) RENICE="renice -n $NICE" ;; #while in UNIX it is relative change (lower priority)
esac
NICE="nice -n $NICE"

Expand Down

0 comments on commit 0023cb9

Please sign in to comment.