Oracle DR: Complete Windows VM implementation and cleanup
Major changes: - Implemented Windows VM 109 as DR target (replaces Linux LXC) - Tested RMAN restore successfully (12-15 min RTO, 24h RPO) - Added comprehensive DR documentation: * DR_WINDOWS_VM_STATUS_2025-10-09.md - Current implementation status * DR_UPGRADE_TO_CUMULATIVE_PLAN.md - Plan for cumulative incremental backups * DR_VM_MIGRATION_GUIDE.md - Guide for VM migration between Proxmox nodes - Updated DR_WINDOWS_VM_IMPLEMENTATION_PLAN.md with completed phases New scripts: - add_system_key_dr.ps1 - SSH key setup for automated transfers - configure_listener_dr.ps1 - Oracle Listener configuration - fix_ssh_via_service.ps1 - SSH authentication fix - rman_restore_final.cmd - Working RMAN restore script (tested) - transfer_to_dr.ps1 - FULL backup transfer (renamed from 02_*) - transfer_incremental.ps1 - Incremental backup transfer (renamed from 02b_*) Cleanup: - Removed 19 obsolete scripts for Linux LXC DR - Removed 8 outdated documentation files - Organized project structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
130
oracle/standby-server-scripts/transfer_incremental.ps1
Normal file
130
oracle/standby-server-scripts/transfer_incremental.ps1
Normal file
@@ -0,0 +1,130 @@
|
||||
# Transfer Oracle INCREMENTAL Backup towards DR Server
|
||||
# Rulează după backup incremental (14:30)
|
||||
# Mai simplu decât scriptul full - doar transferă fișierele noi
|
||||
|
||||
param(
|
||||
[string]$SourceFRA = "C:\Users\Oracle\recovery_area\ROA",
|
||||
[string]$DRHost = "10.0.20.37",
|
||||
[int]$DRPort = 22122,
|
||||
[string]$DRUser = "romfast",
|
||||
[string]$DRPath = "D:/oracle/backups/primary",
|
||||
[string]$SSHKeyPath = "$env:USERPROFILE\.ssh\id_rsa",
|
||||
[string]$LogFile = "D:\rman_backup\logs\transfer_incr_$(Get-Date -Format 'yyyyMMdd_HHmm').log"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Continue"
|
||||
|
||||
function Write-Log {
|
||||
param([string]$Message, [string]$Level = "INFO")
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
$logLine = "[$timestamp] [$Level] $Message"
|
||||
Write-Host $logLine
|
||||
Add-Content -Path $LogFile -Value $logLine -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
function Get-IncrementalBackups {
|
||||
Write-Log "Searching for incremental backup files created in last 2 hours..."
|
||||
|
||||
$cutoffTime = (Get-Date).AddHours(-2)
|
||||
$backupFiles = @()
|
||||
|
||||
# Caută în BACKUPSET, AUTOBACKUP
|
||||
$searchPaths = @(
|
||||
"$SourceFRA\BACKUPSET",
|
||||
"$SourceFRA\AUTOBACKUP"
|
||||
)
|
||||
|
||||
foreach ($path in $searchPaths) {
|
||||
if (Test-Path $path) {
|
||||
$files = Get-ChildItem -Path $path -Recurse -File -ErrorAction SilentlyContinue |
|
||||
Where-Object {
|
||||
$_.LastWriteTime -gt $cutoffTime -and
|
||||
$_.Name -match '\.(BKP|bkp)$'
|
||||
}
|
||||
$backupFiles += $files
|
||||
}
|
||||
}
|
||||
|
||||
return $backupFiles
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Log "========================================="
|
||||
Write-Log "Oracle INCREMENTAL Backup Transfer Started"
|
||||
Write-Log "========================================="
|
||||
Write-Log "Source FRA: $SourceFRA"
|
||||
Write-Log "DR Server: $DRHost"
|
||||
|
||||
# Test SSH connection
|
||||
Write-Log "Testing SSH connection to $DRHost`:$DRPort..."
|
||||
$null = & ssh -n -p $DRPort -i $SSHKeyPath -o StrictHostKeyChecking=no -o ConnectTimeout=10 "${DRUser}@${DRHost}" "exit 0" 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "SSH connection failed"
|
||||
}
|
||||
Write-Log "SSH connection OK" "SUCCESS"
|
||||
|
||||
# Găsește backup-uri incrementale
|
||||
$backupFiles = Get-IncrementalBackups
|
||||
|
||||
if ($backupFiles.Count -eq 0) {
|
||||
Write-Log "⚠️ No incremental backup files found (this might be normal if backup didn't run yet)" "WARNING"
|
||||
exit 0
|
||||
}
|
||||
|
||||
$totalSizeGB = ($backupFiles | Measure-Object -Property Length -Sum).Sum / 1GB
|
||||
Write-Log "Found $($backupFiles.Count) incremental files, total size: $([math]::Round($totalSizeGB, 2)) GB"
|
||||
|
||||
# Transfer fișiere
|
||||
Write-Log "Starting file transfer..."
|
||||
$successCount = 0
|
||||
$failCount = 0
|
||||
|
||||
foreach ($file in $backupFiles) {
|
||||
$fileName = $file.Name
|
||||
$fileSizeMB = [math]::Round($file.Length / 1MB, 2)
|
||||
|
||||
# Check dacă fișierul există deja pe DR (skip duplicates) - Windows PowerShell command
|
||||
$checkCmd = "powershell -Command `"Test-Path '$DRPath/$fileName'`""
|
||||
$checkResult = & ssh -n -p $DRPort -i $SSHKeyPath "${DRUser}@${DRHost}" $checkCmd 2>&1
|
||||
|
||||
if ($checkResult -match "True") {
|
||||
Write-Log "Skipping (already on DR): $fileName" "INFO"
|
||||
$successCount++
|
||||
continue
|
||||
}
|
||||
|
||||
Write-Log "Transferring: $fileName ($fileSizeMB MB)"
|
||||
|
||||
# SCP optimized: no compression (already compressed), fast cipher
|
||||
$null = & scp -P $DRPort -i $SSHKeyPath -o StrictHostKeyChecking=no -o Compression=no -o Cipher=aes128-gcm@openssh.com `
|
||||
$file.FullName `
|
||||
"${DRUser}@${DRHost}:${DRPath}/$fileName" 2>&1
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Log "Transferred: $fileName" "SUCCESS"
|
||||
$successCount++
|
||||
} else {
|
||||
Write-Log "Failed to transfer: $fileName" "ERROR"
|
||||
$failCount++
|
||||
}
|
||||
}
|
||||
|
||||
Write-Log "========================================="
|
||||
Write-Log "Transfer summary: $successCount succeeded, $failCount failed"
|
||||
|
||||
if ($failCount -gt 0) {
|
||||
Write-Log "⚠️ Some transfers failed!" "WARNING"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Log "========================================="
|
||||
Write-Log "INCREMENTAL Backup Transfer Completed Successfully"
|
||||
Write-Log "========================================="
|
||||
Write-Log "Files transferred: $successCount/$($backupFiles.Count)"
|
||||
|
||||
exit 0
|
||||
|
||||
} catch {
|
||||
Write-Log "CRITICAL ERROR: $($_.Exception.Message)" "ERROR"
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user