Compare commits
2 Commits
6accd1f996
...
9ed0ee9e0e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ed0ee9e0e | ||
|
|
f79331f7cc |
@@ -2,6 +2,13 @@
|
|||||||
# Backups are on F:\ (NFS mount from Proxmox host)
|
# Backups are on F:\ (NFS mount from Proxmox host)
|
||||||
# Run as: Administrator
|
# Run as: Administrator
|
||||||
# Location: D:\oracle\scripts\rman_restore_from_zero.ps1
|
# 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"
|
$ErrorActionPreference = "Continue"
|
||||||
|
|
||||||
@@ -201,18 +208,47 @@ if ($LASTEXITCODE -ne 0) {
|
|||||||
} else {
|
} else {
|
||||||
Write-Host "[OK] SPFILE created successfully"
|
Write-Host "[OK] SPFILE created successfully"
|
||||||
|
|
||||||
# Recreate service with auto-start and SPFILE
|
# Check if running in TestMode (weekly DR test)
|
||||||
Write-Host "[3.3] Recreating Oracle service with auto-start mode..."
|
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
|
& oradim -delete -sid ROA 2>&1 | Out-Null
|
||||||
Start-Sleep -Seconds 2
|
Start-Sleep -Seconds 2
|
||||||
& oradim -new -sid ROA -startmode auto -spfile 2>&1 | Out-Null
|
& oradim -new -sid ROA -startmode auto -spfile 2>&1 | Out-Null
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-Host "WARNING: Failed to recreate service with auto-start" -ForegroundColor Yellow
|
Write-Host " WARNING: Failed to recreate service with SPFILE" -ForegroundColor Yellow
|
||||||
} else {
|
} else {
|
||||||
Write-Host "[OK] Service recreated with auto-start mode"
|
Write-Host " [OK] Service now configured with SPFILE and AUTOMATIC startup"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Register with listener and start it
|
# 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..."
|
Write-Host "[3.4] Starting Oracle Listener..."
|
||||||
|
|
||||||
# Set Listener service to AUTOMATIC and start it
|
# Set Listener service to AUTOMATIC and start it
|
||||||
@@ -236,6 +272,7 @@ EXIT;
|
|||||||
$registerSQL | & sqlplus -S / as sysdba 2>&1 | Out-Null
|
$registerSQL | & sqlplus -S / as sysdba 2>&1 | Out-Null
|
||||||
Write-Host "[OK] Database registered with Listener"
|
Write-Host "[OK] Database registered with Listener"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "============================================"
|
Write-Host "============================================"
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ run_dr_test() {
|
|||||||
log "STEP 4: Running database restore"
|
log "STEP 4: Running database restore"
|
||||||
|
|
||||||
if ssh -p "$DR_VM_PORT" "$DR_VM_USER@$DR_VM_IP" \
|
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)
|
local restore_end=$(date +%s)
|
||||||
restore_duration=$(( (restore_end - restore_start) / 60 ))
|
restore_duration=$(( (restore_end - restore_start) / 60 ))
|
||||||
|
|||||||
Reference in New Issue
Block a user