diff --git a/oracle/standby-server-scripts/weekly-dr-test-proxmox.sh b/oracle/standby-server-scripts/weekly-dr-test-proxmox.sh index 8f60a95..946dc44 100644 --- a/oracle/standby-server-scripts/weekly-dr-test-proxmox.sh +++ b/oracle/standby-server-scripts/weekly-dr-test-proxmox.sh @@ -90,12 +90,17 @@ WARNINGS {{/each}} {{/if}} -RESTORE LOG (first 200 lines) +RMAN RESTORE LOG (complete) --- {{restore_log}} --- -Log: {{log_file}} +BASH SCRIPT LOG (last 100 lines) +--- +{{bash_log}} +--- + +Full log: {{log_file}} Next test: Saturday 06:00 EOF @@ -183,15 +188,24 @@ EOF - +
Restore Log (first 200 lines)
RMAN Restore Log (complete)
{{restore_log}}
+ + + + + +
Bash Script Log (last 100 lines)
{{bash_log}}
+ + + - Log: {{log_file}} · Next test: Saturday 06:00 + Full log: {{log_file}} · Next test: Saturday 06:00 @@ -373,9 +387,16 @@ run_dr_test() { step_start=$(date +%s) log "STEP 5: Verifying database" - # Use PowerShell to query database status + # Use PowerShell to query database status (check if contains READ WRITE anywhere) db_status=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \ - "powershell -Command \"echo 'SELECT OPEN_MODE FROM V\`\$DATABASE;' | sqlplus -s / as sysdba | Select-String 'READ WRITE'\"" 2>/dev/null || echo "") + "powershell -Command \"echo 'SELECT OPEN_MODE FROM V\`\$DATABASE;' | sqlplus -s / as sysdba | Out-String | Select-String -Pattern 'READ WRITE' -Quiet\"" 2>/dev/null || echo "false") + + # Convert PowerShell True/False to bash-friendly value + if [[ "$db_status" == *"True"* ]] || [[ "$db_status" == "True" ]]; then + db_status="READ WRITE" + else + db_status="" + fi # Use PowerShell to count tables tables_restored=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \ @@ -392,15 +413,15 @@ run_dr_test() { track_step "Database Verification" false "Database not OPEN" "$step_start" fi - # Collect restore log from VM (always attempt collection) + # Collect restore log from VM (always attempt collection - FULL log) log "Collecting restore log from DR VM..." restore_log=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \ - "powershell -Command \"Get-Content 'D:\\oracle\\logs\\restore_from_zero.log' -Head 200 -ErrorAction SilentlyContinue\"" 2>/dev/null || echo "") + "powershell -Command \"Get-Content 'D:\\oracle\\logs\\restore_from_zero.log' -ErrorAction SilentlyContinue\"" 2>/dev/null || echo "") # If not found, try alternate locations if [ -z "$restore_log" ]; then restore_log=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \ - "powershell -Command \"Get-Content 'D:\\oracle\\temp\\restore_from_zero.log' -Head 200 -ErrorAction SilentlyContinue\"" 2>/dev/null || echo "") + "powershell -Command \"Get-Content 'D:\\oracle\\temp\\restore_from_zero.log' -ErrorAction SilentlyContinue\"" 2>/dev/null || echo "") fi # Still not found, use fallback message @@ -419,14 +440,14 @@ run_dr_test() { track_step "Cleanup" true "Database cleaned, ~${cleanup_freed}GB freed" "$step_start" else - # Collect restore log even when restore fails + # Collect restore log even when restore fails (FULL log) log "Collecting restore log after failure..." restore_log=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \ - "powershell -Command \"Get-Content 'D:\\oracle\\logs\\restore_from_zero.log' -Head 200 -ErrorAction SilentlyContinue\"" 2>/dev/null || echo "") + "powershell -Command \"Get-Content 'D:\\oracle\\logs\\restore_from_zero.log' -ErrorAction SilentlyContinue\"" 2>/dev/null || echo "") if [ -z "$restore_log" ]; then restore_log=$(ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \ - "powershell -Command \"Get-Content 'D:\\oracle\\temp\\restore_from_zero.log' -Head 200 -ErrorAction SilentlyContinue\"" 2>/dev/null || echo "") + "powershell -Command \"Get-Content 'D:\\oracle\\temp\\restore_from_zero.log' -ErrorAction SilentlyContinue\"" 2>/dev/null || echo "") fi # Always try to get some error output from RMAN script @@ -500,6 +521,12 @@ run_dr_test() { # Escape restore log for JSON local restore_log_json restore_log_json=$(echo "$restore_log" | jq -Rs .) + + # Collect last 100 lines of bash script log + local bash_log + bash_log=$(tail -100 "$LOG_FILE" 2>/dev/null || echo "Bash log not available") + local bash_log_json + bash_log_json=$(echo "$bash_log" | jq -Rs .) local json_data=$(cat <