Oracle DR: Fix RMAN crosscheck sequence and improve error handling
- Fix CROSSCHECK BACKUP command to execute after database is mounted - Correct CATALOG command to use recovery_area instead of F:\ path - Add robust backup file validation with detailed error reporting - Improve file-by-file backup copying with individual error tracking - Enhance restore log collection for both success and failure scenarios - Fix database verification to check OPEN_MODE instead of STATUS - Add comprehensive directory and permissions error handling Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
@@ -375,7 +375,7 @@ run_dr_test() {
|
||||
|
||||
# Use PowerShell to query database status
|
||||
db_status=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \
|
||||
"powershell -Command \"'SELECT STATUS FROM V\`\$INSTANCE;' | sqlplus -s / as sysdba | Select-String 'OPEN'\"" || echo "")
|
||||
"powershell -Command \"'SELECT OPEN_MODE FROM V\\\$DATABASE;' | sqlplus -s / as sysdba | findstr 'READ WRITE'\"" || echo "")
|
||||
|
||||
# Use PowerShell to count tables
|
||||
tables_restored=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \
|
||||
@@ -383,7 +383,7 @@ run_dr_test() {
|
||||
tables_restored=$(echo "$tables_restored" | tr -cd '0-9')
|
||||
[ -z "$tables_restored" ] && tables_restored=0
|
||||
|
||||
if [[ "$db_status" =~ "OPEN" ]]; then
|
||||
if [[ "$db_status" =~ "READ WRITE" ]]; then
|
||||
track_step "Database Verification" true "Database OPEN, $tables_restored tables" "$step_start"
|
||||
test_result="PASSED"
|
||||
severity="info"
|
||||
@@ -392,10 +392,26 @@ run_dr_test() {
|
||||
track_step "Database Verification" false "Database not OPEN" "$step_start"
|
||||
fi
|
||||
|
||||
# Collect restore log from VM
|
||||
# Collect restore log from VM (always attempt collection)
|
||||
log "Collecting restore log from DR VM..."
|
||||
restore_log=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \
|
||||
"type D:\\oracle\\logs\\restore_from_zero.log 2>nul" | head -200 || echo "Log not available")
|
||||
|
||||
# If not found, try alternate locations
|
||||
if [[ "$restore_log" == *"Log not available"* ]]; then
|
||||
restore_log=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \
|
||||
"type D:\\oracle\\temp\\restore_from_zero.log 2>nul" | head -200 || echo "Log not available")
|
||||
fi
|
||||
|
||||
# Still not found, check if any logs exist
|
||||
if [[ "$restore_log" == *"Log not available"* ]]; then
|
||||
log "Checking for any restore logs in DR VM..."
|
||||
log_check=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \
|
||||
"dir D:\\oracle\\logs\\*.log 2>nul || dir D:\\oracle\\temp\\*.log 2>nul || echo 'No logs found'" 2>/dev/null || echo "Connection error")
|
||||
if [[ "$log_check" != *"No logs found"* ]]; then
|
||||
restore_log="Log files found but could not be read. Available files: $log_check"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Step 6: Cleanup
|
||||
step_start=$(date +%s)
|
||||
@@ -408,6 +424,25 @@ run_dr_test() {
|
||||
track_step "Cleanup" true "Database cleaned, ~${cleanup_freed}GB freed" "$step_start"
|
||||
|
||||
else
|
||||
# Collect restore log even when restore fails
|
||||
log "Collecting restore log after failure..."
|
||||
restore_log=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \
|
||||
"type D:\\oracle\\logs\\restore_from_zero.log 2>nul" | head -200 || echo "Log not available")
|
||||
|
||||
if [[ "$restore_log" == *"Log not available"* ]]; then
|
||||
restore_log=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \
|
||||
"type D:\\oracle\\temp\\restore_from_zero.log 2>nul" | head -200 || echo "Log not available")
|
||||
fi
|
||||
|
||||
# Always try to get some error output
|
||||
if [[ "$restore_log" == *"Log not available"* ]]; then
|
||||
last_error=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \
|
||||
"powershell -Command 'Get-Content D:\\oracle\\temp\\*.rman -Tail 20 || echo \"No RMAN script found\"'" 2>/dev/null || echo "Cannot access RMAN script")
|
||||
if [[ "$last_error" != *"No RMAN script found"* ]]; then
|
||||
restore_log="RMAN script content (last 20 lines):$last_error"
|
||||
fi
|
||||
fi
|
||||
|
||||
track_step "Database Restore" false "Restore failed" "$step_start"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user