diff --git a/oracle/standby-server-scripts/weekly-dr-test-proxmox.sh b/oracle/standby-server-scripts/weekly-dr-test-proxmox.sh index b9cc586..15b6d4e 100644 --- a/oracle/standby-server-scripts/weekly-dr-test-proxmox.sh +++ b/oracle/standby-server-scripts/weekly-dr-test-proxmox.sh @@ -423,24 +423,21 @@ run_dr_test() { step_start=$(date +%s) log "STEP 5: Verifying database" - # 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 | 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 + # Parse database status from LOG_FILE (rman_restore_from_zero.ps1 already verified it) + # Look for "OPEN_MODE: READ WRITE" in the captured output + if grep -q "OPEN_MODE: READ WRITE" "$LOG_FILE" 2>/dev/null; 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" \ - "powershell -Command \"'SELECT COUNT(*) FROM DBA_TABLES WHERE OWNER NOT IN (''SYS'',''SYSTEM'');' | sqlplus -s / as sysdba | Select-String -Pattern '[0-9]+' | ForEach-Object { \$_.Matches[0].Value } | Select-Object -Last 1\"" || echo "0") + # Parse table count from LOG_FILE (already captured in STEP 3 output) + # Look for "TABLES: " in the output + tables_restored=$(grep -oP "TABLES:\s*\K\d+" "$LOG_FILE" 2>/dev/null | tail -1 || echo "0") tables_restored=$(echo "$tables_restored" | tr -cd '0-9') [ -z "$tables_restored" ] && tables_restored=0 - if [[ "$db_status" =~ "READ WRITE" ]]; then + if [[ "$db_status" == "READ WRITE" ]] && [ "$tables_restored" -gt 0 ]; then track_step "Database Verification" true "Database OPEN, $tables_restored tables" "$step_start" test_result="PASSED" severity="info"