WIP: Oracle DR CUMULATIVE backup upgrade - Phases 1-3 completed

COMPLETED:
- Phase 1: Proxmox host storage (/mnt/pve/oracle-backups/ROA/autobackup)
- Phase 2: RMAN script already has CUMULATIVE keyword
- Phase 3: Transfer scripts updated for Proxmox host
  * transfer_incremental.ps1: 10.0.20.37:22122 → 10.0.20.202:22
  * transfer_to_dr.ps1: Same change
  * Converted Windows PowerShell to Linux bash commands
- VM 109 cleanup: ~6.4 GB freed, RMAN catalog cleaned

NEW FILES:
- copy_existing_key_to_proxmox.ps1: Setup script for SSH key
- setup_ssh_keys_for_proxmox.ps1: Alternative setup (not used)

PENDING (Next Session):
- Run copy_existing_key_to_proxmox.ps1 on PRIMARY as Administrator
- Phase 4: Modify scheduled tasks (13:00 + 18:00)
- Phase 5: Configure mount point on VM 109 (F:\ drive)
- Phase 6: Update restore script for F:\ mount
- Phase 7: Test FULL + CUMULATIVE backup and restore

DOCUMENTATION:
- DR_UPGRADE_TO_CUMULATIVE_PLAN.md: Added implementation status

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Marius
2025-10-09 22:45:32 +03:00
parent ac2340c967
commit ec77bb3ddf
8 changed files with 626 additions and 18 deletions

View File

@@ -1,12 +1,45 @@
# Oracle DR - Upgrade to Cumulative Incremental Backup Strategy
**Generated:** 2025-10-09
**Last Updated:** 2025-10-09 19:00
**Status:** 🟡 IN PROGRESS - Phases 1-3 COMPLETED
**Objective:** Implement cumulative incremental backups with Proxmox host storage for optimal RPO/RTO
**Target RPO:** 3-4 hours (vs current 24 hours)
**Target RTO:** 12-15 minutes (unchanged)
---
## ✅ IMPLEMENTATION STATUS
### Completed (2025-10-09)
-**Phase 1:** Proxmox host storage configured (`/mnt/pve/oracle-backups/ROA/autobackup`)
-**Phase 2:** RMAN script already has `CUMULATIVE` keyword
-**Phase 3:** Transfer scripts updated to send to Proxmox (10.0.20.202:22, root)
- Modified: `transfer_incremental.ps1` and `transfer_to_dr.ps1`
- Changed from VM 109 (10.0.20.37:22122) to Proxmox host
- Converted Windows PowerShell commands to Linux bash
-**VM 109 cleanup:** Deleted temporary files, old backups (~6.4 GB freed)
### Pending (Next Session)
-**SSH Key Setup:** Run `copy_existing_key_to_proxmox.ps1` on PRIMARY as Administrator
- Existing key: `C:\Windows\System32\config\systemprofile\.ssh\id_rsa`
- Copy to: Proxmox `/root/.ssh/authorized_keys`
-**Phase 4:** Modify scheduled tasks (13:00 + 18:00)
-**Phase 5:** Configure mount point on VM 109 (will appear as F:\)
-**Phase 6:** Update restore script to use F:\ mount
-**Phase 7:** Test FULL + CUMULATIVE backup and restore
### Files Modified
```
oracle/standby-server-scripts/
├── transfer_incremental.ps1 [MODIFIED] → Proxmox host
├── transfer_to_dr.ps1 [MODIFIED] → Proxmox host
├── rman_backup_incremental.txt [ALREADY OK] → Has CUMULATIVE
└── copy_existing_key_to_proxmox.ps1 [NEW] → Setup script for SSH key
```
---
## 📋 EXECUTIVE SUMMARY
### Current State

View File

@@ -0,0 +1,78 @@
# Copy Existing SSH Key to Proxmox
# Rulează acest script pe PRIMARY ca Administrator
#
# Acest script copiază cheia publică SSH existentă din profilul SYSTEM pe Proxmox
param(
[string]$ProxmoxHost = "10.0.20.202",
[string]$ProxmoxUser = "root"
)
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host "Copiere Cheie SSH Existentă → Proxmox DR" -ForegroundColor Cyan
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host ""
$SystemSSHDir = "C:\Windows\System32\config\systemprofile\.ssh"
$PublicKeyPath = "$SystemSSHDir\id_rsa.pub"
$PrivateKeyPath = "$SystemSSHDir\id_rsa"
# Verifică dacă cheia există
if (-not (Test-Path $PublicKeyPath)) {
Write-Host "✗ Cheia publică nu există: $PublicKeyPath" -ForegroundColor Red
Write-Host " Scriptul trebuie rulat ca Administrator!" -ForegroundColor Yellow
exit 1
}
Write-Host "✓ Cheie publică găsită: $PublicKeyPath" -ForegroundColor Green
Write-Host ""
Write-Host "→ Copiez cheia publică pe Proxmox ($ProxmoxHost)..." -ForegroundColor Yellow
Write-Host " IMPORTANT: Vei fi întrebat de parola root pentru Proxmox!" -ForegroundColor Cyan
Write-Host ""
# Metodă simplă: folosim SCP pentru a copia fișierul temporar, apoi cat
$tempFile = "C:\Windows\Temp\temp_pubkey.pub"
Copy-Item $PublicKeyPath $tempFile -Force
# Copiază fișierul pe Proxmox
& scp $tempFile "${ProxmoxUser}@${ProxmoxHost}:/tmp/temp_pubkey.pub"
if ($LASTEXITCODE -ne 0) {
Write-Host "✗ Eroare la copierea fișierului cu SCP" -ForegroundColor Red
Remove-Item $tempFile -Force -ErrorAction SilentlyContinue
exit 1
}
# Adaugă cheia în authorized_keys
& ssh "${ProxmoxUser}@${ProxmoxHost}" "mkdir -p /root/.ssh; chmod 700 /root/.ssh; cat /tmp/temp_pubkey.pub >> /root/.ssh/authorized_keys; chmod 600 /root/.ssh/authorized_keys; rm /tmp/temp_pubkey.pub; echo 'SSH key added'"
Remove-Item $tempFile -Force -ErrorAction SilentlyContinue
if ($LASTEXITCODE -eq 0) {
Write-Host "✓ Cheie publică copiată pe Proxmox!" -ForegroundColor Green
} else {
Write-Host "✗ Eroare la adăugarea cheii în authorized_keys" -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "→ Testez conexiunea SSH fără parolă..." -ForegroundColor Yellow
# Testează conexiunea (cu cheia din profilul SYSTEM)
$testResult = & ssh -o StrictHostKeyChecking=no -i $PrivateKeyPath "${ProxmoxUser}@${ProxmoxHost}" "echo 'SSH connection OK'" 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "✓ Conexiune SSH funcționează fără parolă!" -ForegroundColor Green
} else {
Write-Host "✗ Conexiunea SSH nu funcționează direct din acest cont" -ForegroundColor Yellow
Write-Host " Dar cheia a fost adăugată - scheduled tasks (SYSTEM) ar trebui să funcționeze" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "=========================================" -ForegroundColor Green
Write-Host "✓ Setup complet!" -ForegroundColor Green
Write-Host "=========================================" -ForegroundColor Green
Write-Host ""
Write-Host "Cheia din profilul SYSTEM: $PrivateKeyPath" -ForegroundColor Cyan
Write-Host "Scheduled tasks vor folosi această cheie automat." -ForegroundColor Yellow
Write-Host ""

View File

@@ -4,10 +4,10 @@
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]$DRHost = "10.0.20.202",
[int]$DRPort = 22,
[string]$DRUser = "root",
[string]$DRPath = "/mnt/pve/oracle-backups/ROA/autobackup",
[string]$SSHKeyPath = "$env:USERPROFILE\.ssh\id_rsa",
[string]$LogFile = "D:\rman_backup\logs\transfer_incr_$(Get-Date -Format 'yyyyMMdd_HHmm').log"
)
@@ -83,8 +83,8 @@ try {
$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'`""
# Check dacă fișierul există deja pe DR (skip duplicates) - Linux bash command
$checkCmd = "test -f '$DRPath/$fileName' && echo 'True' || echo 'False'"
$checkResult = & ssh -n -p $DRPort -i $SSHKeyPath "${DRUser}@${DRHost}" $checkCmd 2>&1
if ($checkResult -match "True") {

View File

@@ -4,10 +4,10 @@
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]$DRHost = "10.0.20.202",
[int]$DRPort = 22,
[string]$DRUser = "root",
[string]$DRPath = "/mnt/pve/oracle-backups/ROA/autobackup",
[string]$SSHKeyPath = "$env:USERPROFILE\.ssh\id_rsa",
[int]$RetentionDays = 2,
[string]$LogFile = "D:\rman_backup\logs\transfer_$(Get-Date -Format 'yyyyMMdd').log"
@@ -87,8 +87,8 @@ function Transfer-FileToDR {
$fileSizeMB = [math]::Round($File.Length / 1MB, 2)
try {
# Check dacă fișierul există deja pe DR (skip duplicates) - Windows PowerShell command
$checkCmd = "powershell -Command `"Test-Path '$DestPath/$fileName'`""
# Check dacă fișierul există deja pe DR (skip duplicates) - Linux bash command
$checkCmd = "test -f '$DestPath/$fileName' && echo 'True' || echo 'False'"
$checkResult = & ssh -n -p $DRPort -i $SSHKeyPath "${DRUser}@${DRHost}" $checkCmd 2>&1
if ($checkResult -match "True") {
@@ -119,12 +119,11 @@ function Cleanup-OldBackupsOnDR {
Write-Log "Cleaning up old backups on DR (keeping last $RetentionDays days)..."
try {
# Cleanup: șterge fișiere mai vechi de $RetentionDays zile - Windows PowerShell command
$retentionDate = (Get-Date).AddDays(-$RetentionDays).ToString("yyyy-MM-dd")
$cleanupCmd = "powershell -Command `"Get-ChildItem -Path '$DRPath' -Recurse -File | Where-Object { `$_.LastWriteTime -lt '$retentionDate' } | Remove-Item -Force -ErrorAction SilentlyContinue`""
# Cleanup: șterge fișiere mai vechi de $RetentionDays zile - Linux find command
$cleanupCmd = "find '$DRPath' -type f -mtime +$RetentionDays -delete 2>/dev/null || true"
$result = & ssh -n -p $DRPort -i $SSHKeyPath "${DRUser}@${DRHost}" $cleanupCmd 2>&1
Write-Log "Cleanup completed on DR (removed files older than $retentionDate)"
Write-Log "Cleanup completed on DR (removed files older than $RetentionDays days)"
} catch {
Write-Log "Cleanup warning: $_" "WARNING"
}
@@ -154,9 +153,9 @@ try {
throw "Cannot connect to DR server via SSH"
}
# Creare director pe DR - Windows PowerShell command
# Creare director pe DR - Linux mkdir command
Write-Log "Ensuring DR directory exists..."
$null = & ssh -n -p $DRPort -i $SSHKeyPath "${DRUser}@${DRHost}" "powershell -Command `"New-Item -ItemType Directory -Path '$DRPath' -Force | Out-Null`"" 2>&1
$null = & ssh -n -p $DRPort -i $SSHKeyPath "${DRUser}@${DRHost}" "mkdir -p '$DRPath'" 2>&1
# Găsește backup-uri
$backupFiles = Get-TodaysBackups