Oracle DR: Optimize test speed by preserving service between tests

Performance improvements:
- cleanup_database.ps1: Skip service deletion (saves ~25s per test)
  - Remove oradim -delete, sc.exe delete, registry cleanup
  - Add SPFILE deletion to ensure PFILE-based startup
  - Service now persists between tests for reuse

- rman_restore_from_zero.ps1: Smart service check (saves ~15s per test)
  - Check if service exists before creating
  - Skip oradim -new if service already present
  - Only create service on first run or if missing

Total time savings: ~40 seconds per weekly DR test
Service lifecycle: Created once, reused indefinitely until manual cleanup

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
Marius
2025-10-11 10:59:43 +03:00
parent 3a51880c9e
commit 5bed910b1c
2 changed files with 31 additions and 43 deletions

View File

@@ -81,21 +81,30 @@ Write-Host "STEP 2: RESTORE - Restore from F:\ backups"
Write-Host "============================================"
Write-Host ""
# Step 2.1: Create Oracle service
Write-Host "[2.1] Creating Oracle service from PFILE..."
if (-not (Test-Path "C:\Users\oracle\admin\ROA\pfile\initROA.ora")) {
Write-Host "ERROR: PFILE not found at C:\Users\oracle\admin\ROA\pfile\initROA.ora" -ForegroundColor Red
Write-Host "Cannot create Oracle service without PFILE!"
exit 1
}
# Step 2.1: Check Oracle service (create only if missing)
Write-Host "[2.1] Checking Oracle service..."
$service = Get-Service -Name "OracleServiceROA" -ErrorAction SilentlyContinue
& oradim -new -sid ROA -startmode auto -pfile "C:\Users\oracle\admin\ROA\pfile\initROA.ora" 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Failed to create Oracle service" -ForegroundColor Red
exit 1
if ($service) {
Write-Host "[OK] Oracle service already exists, skipping creation (15s saved!)" -ForegroundColor Green
Write-Host " Service will be reused for this restore"
} else {
Write-Host " Oracle service not found, creating from PFILE..."
if (-not (Test-Path "C:\Users\oracle\admin\ROA\pfile\initROA.ora")) {
Write-Host "ERROR: PFILE not found at C:\Users\oracle\admin\ROA\pfile\initROA.ora" -ForegroundColor Red
Write-Host "Cannot create Oracle service without PFILE!"
exit 1
}
& oradim -new -sid ROA -startmode auto -pfile "C:\Users\oracle\admin\ROA\pfile\initROA.ora" 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Failed to create Oracle service" -ForegroundColor Red
exit 1
}
Write-Host "[OK] Oracle service created successfully (AUTOMATIC startup)"
Start-Sleep -Seconds 2
}
Write-Host "[OK] Oracle service created successfully (AUTOMATIC startup)"
Start-Sleep -Seconds 2
# Step 2.2: Startup NOMOUNT
Write-Host "[2.2] Starting database in NOMOUNT mode..."