Oracle DR: Add TestMode parameter for dual behavior
rman_restore_from_zero.ps1: - Add -TestMode switch parameter - TestMode (weekly DR test): Skip service/listener config, only verify restore works - Standalone mode: Full config with SPFILE + Listener for production use weekly-dr-test-proxmox.sh: - Call restore script with -TestMode flag - Avoids service recreation and SSH disconnect during tests Benefits: - Weekly tests are faster and cleaner (no service restart) - Manual restore prepares system for production use - No more 'Broken pipe' errors during tests Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
# Backups are on F:\ (NFS mount from Proxmox host)
|
||||
# Run as: Administrator
|
||||
# Location: D:\oracle\scripts\rman_restore_from_zero.ps1
|
||||
#
|
||||
# Parameters:
|
||||
# -TestMode: Skip service reconfiguration and Listener startup (for weekly DR tests)
|
||||
|
||||
param(
|
||||
[switch]$TestMode
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Continue"
|
||||
|
||||
@@ -200,7 +207,46 @@ if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "WARNING: Failed to create SPFILE - database may not persist after connections close" -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host "[OK] SPFILE created successfully"
|
||||
Write-Host "[3.3] Oracle service already configured with AUTOMATIC startup (from step 2.1)"
|
||||
|
||||
# Check if running in TestMode (weekly DR test)
|
||||
if ($TestMode) {
|
||||
Write-Host "[3.3] Running in TEST MODE - skipping service reconfiguration"
|
||||
Write-Host " Database is OPEN and ready for verification"
|
||||
Write-Host " Service will remain configured with PFILE (OK for testing)"
|
||||
} else {
|
||||
# Full configuration for standalone/production use
|
||||
Write-Host "[3.3] Reconfiguring Oracle service to use SPFILE..."
|
||||
|
||||
# Shutdown database cleanly
|
||||
Write-Host " Shutting down database temporarily..."
|
||||
$shutdownSQL = @"
|
||||
SHUTDOWN IMMEDIATE;
|
||||
EXIT;
|
||||
"@
|
||||
$shutdownSQL | & sqlplus -S / as sysdba 2>&1 | Out-Null
|
||||
Start-Sleep -Seconds 3
|
||||
|
||||
# Delete and recreate service with SPFILE
|
||||
Write-Host " Recreating service with SPFILE..."
|
||||
& oradim -delete -sid ROA 2>&1 | Out-Null
|
||||
Start-Sleep -Seconds 2
|
||||
& oradim -new -sid ROA -startmode auto -spfile 2>&1 | Out-Null
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host " WARNING: Failed to recreate service with SPFILE" -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host " [OK] Service now configured with SPFILE and AUTOMATIC startup"
|
||||
}
|
||||
|
||||
# Restart database
|
||||
Write-Host " Starting database with SPFILE..."
|
||||
$startupSQL = @"
|
||||
STARTUP;
|
||||
EXIT;
|
||||
"@
|
||||
$startupSQL | & sqlplus -S / as sysdba 2>&1 | Out-Null
|
||||
Start-Sleep -Seconds 3
|
||||
Write-Host "[OK] Database restarted with SPFILE configuration"
|
||||
|
||||
# Start Oracle Listener
|
||||
Write-Host "[3.4] Starting Oracle Listener..."
|
||||
@@ -225,6 +271,7 @@ EXIT;
|
||||
"@
|
||||
$registerSQL | & sqlplus -S / as sysdba 2>&1 | Out-Null
|
||||
Write-Host "[OK] Database registered with Listener"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
@@ -362,7 +362,7 @@ run_dr_test() {
|
||||
log "STEP 4: Running database restore"
|
||||
|
||||
if ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \
|
||||
"powershell -ExecutionPolicy Bypass -File D:\\oracle\\scripts\\rman_restore_from_zero.ps1" 2>&1 | tee -a "$LOG_FILE"; then
|
||||
"powershell -ExecutionPolicy Bypass -File D:\\oracle\\scripts\\rman_restore_from_zero.ps1 -TestMode" 2>&1 | tee -a "$LOG_FILE"; then
|
||||
|
||||
local restore_end=$(date +%s)
|
||||
restore_duration=$(( (restore_end - restore_start) / 60 ))
|
||||
|
||||
Reference in New Issue
Block a user