From 8682e0ee047cea97b4c942049d81f91b56c3a2d5 Mon Sep 17 00:00:00 2001 From: Marius Date: Fri, 10 Oct 2025 01:21:47 +0300 Subject: [PATCH] Oracle DR: Complete Phase 5 - NFS mount point configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 5 implementation completed: - NFS server installed on Proxmox (nfs-kernel-server) - NFS export configured: /mnt/pve/oracle-backups → VM 109 - Windows NFS Client enabled in VM 109 - F:\ drive auto-mount at startup via scheduled task - PowerShell script: D:\Oracle\Scripts\mount-nfs.bat - Directory permissions set to 777 for Windows compatibility - Mount persists across VM reboots Files updated: - DR_UPGRADE_TO_CUMULATIVE_PLAN.md: Status → Phases 1-3-5 COMPLETED - Added detailed Phase 5 documentation with step-by-step setup - Updated validation checklist (8 items completed) Next: Phases 4, 6, 7 (scheduled tasks, restore script, testing) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- input/copy_existing_key_to_proxmox.ps1 | 42 ++-- .../DR_UPGRADE_TO_CUMULATIVE_PLAN.md | 202 +++++++++++++++--- 2 files changed, 194 insertions(+), 50 deletions(-) diff --git a/input/copy_existing_key_to_proxmox.ps1 b/input/copy_existing_key_to_proxmox.ps1 index a951db7..d1fd10a 100644 --- a/input/copy_existing_key_to_proxmox.ps1 +++ b/input/copy_existing_key_to_proxmox.ps1 @@ -1,7 +1,7 @@ # Copy Existing SSH Key to Proxmox -# Rulează acest script pe PRIMARY ca Administrator +# Ruleaza acest script pe PRIMARY ca Administrator # -# Acest script copiază cheia publică SSH existentă din profilul SYSTEM pe Proxmox +# Acest script copiaza cheia publica SSH existenta din profilul SYSTEM pe Proxmox param( [string]$ProxmoxHost = "10.0.20.202", @@ -9,7 +9,7 @@ param( ) Write-Host "=========================================" -ForegroundColor Cyan -Write-Host "Copiere Cheie SSH Existentă → Proxmox DR" -ForegroundColor Cyan +Write-Host "Copiere Cheie SSH Existenta -> Proxmox DR" -ForegroundColor Cyan Write-Host "=========================================" -ForegroundColor Cyan Write-Host "" @@ -17,62 +17,62 @@ $SystemSSHDir = "C:\Windows\System32\config\systemprofile\.ssh" $PublicKeyPath = "$SystemSSHDir\id_rsa.pub" $PrivateKeyPath = "$SystemSSHDir\id_rsa" -# Verifică dacă cheia există +# Verifica daca cheia exista if (-not (Test-Path $PublicKeyPath)) { - Write-Host "✗ Cheia publică nu există: $PublicKeyPath" -ForegroundColor Red + Write-Host "X Cheia publica nu exista: $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 "OK Cheie publica gasita: $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 "-> Copiez cheia publica pe Proxmox ($ProxmoxHost)..." -ForegroundColor Yellow +Write-Host " IMPORTANT: Vei fi intrebat de parola root pentru Proxmox!" -ForegroundColor Cyan Write-Host "" -# Metodă simplă: folosim SCP pentru a copia fișierul temporar, apoi cat +# Metoda simpla: folosim SCP pentru a copia fisierul temporar, apoi cat $tempFile = "C:\Windows\Temp\temp_pubkey.pub" Copy-Item $PublicKeyPath $tempFile -Force -# Copiază fișierul pe Proxmox +# Copiaza fisierul 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 + Write-Host "X Eroare la copierea fisierului cu SCP" -ForegroundColor Red Remove-Item $tempFile -Force -ErrorAction SilentlyContinue exit 1 } -# Adaugă cheia în authorized_keys +# Adauga cheia in 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 + Write-Host "OK Cheie publica copiata pe Proxmox!" -ForegroundColor Green } else { - Write-Host "✗ Eroare la adăugarea cheii în authorized_keys" -ForegroundColor Red + Write-Host "X Eroare la adaugarea cheii in authorized_keys" -ForegroundColor Red exit 1 } Write-Host "" -Write-Host "→ Testez conexiunea SSH fără parolă..." -ForegroundColor Yellow +Write-Host "-> Testez conexiunea SSH fara parola..." -ForegroundColor Yellow -# Testează conexiunea (cu cheia din profilul SYSTEM) +# Testeaza 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 + Write-Host "OK Conexiune SSH functioneaza fara parola!" -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 "X Conexiunea SSH nu functioneaza direct din acest cont" -ForegroundColor Yellow + Write-Host " Dar cheia a fost adaugata - scheduled tasks (SYSTEM) ar trebui sa functioneze" -ForegroundColor Yellow } Write-Host "" Write-Host "=========================================" -ForegroundColor Green -Write-Host "✓ Setup complet!" -ForegroundColor Green +Write-Host "OK 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 "Scheduled tasks vor folosi aceasta cheie automat." -ForegroundColor Yellow Write-Host "" diff --git a/oracle/standby-server-scripts/DR_UPGRADE_TO_CUMULATIVE_PLAN.md b/oracle/standby-server-scripts/DR_UPGRADE_TO_CUMULATIVE_PLAN.md index 674a9ab..678bf27 100644 --- a/oracle/standby-server-scripts/DR_UPGRADE_TO_CUMULATIVE_PLAN.md +++ b/oracle/standby-server-scripts/DR_UPGRADE_TO_CUMULATIVE_PLAN.md @@ -1,8 +1,8 @@ # 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 +**Last Updated:** 2025-10-10 00:45 +**Status:** 🟡 IN PROGRESS - Phases 1-3-5 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) @@ -11,7 +11,7 @@ ## ✅ IMPLEMENTATION STATUS -### Completed (2025-10-09) +### Completed (2025-10-09 + 2025-10-10) - ✅ **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) @@ -19,13 +19,20 @@ - 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) +- ✅ **Phase 5:** NFS mount point configured on VM 109 → **F:\ drive** + - NFS server installed on Proxmox: `nfs-kernel-server` + - NFS export configured: `/mnt/pve/oracle-backups → 10.0.20.37 (rw,no_root_squash)` + - NFS Client enabled in Windows VM 109 + - Mount command: `mount -o rw,nolock,mtype=hard,timeout=60 10.0.20.202:/mnt/pve/oracle-backups F:` + - PowerShell scheduled task created for auto-mount at startup (`D:\Oracle\Scripts\mount-nfs.bat`) + - Permissions set to 777 on Proxmox directory + - **Status:** F:\ mounts automatically at Windows startup ✅ ### 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 4:** Modify scheduled tasks on PRIMARY (13:00 + 18:00) - ⏳ **Phase 6:** Update restore script to use F:\ mount - ⏳ **Phase 7:** Test FULL + CUMULATIVE backup and restore @@ -36,6 +43,14 @@ oracle/standby-server-scripts/ ├── 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 + +VM 109 (Windows): +├── C:\Scripts\mount-nfs.ps1 [NEW] → PowerShell script for NFS mount +└── Scheduled Task: "Mount NFS F" [NEW] → Auto-mount at startup + +Proxmox (pveelite): +├── /etc/exports [MODIFIED] → NFS export configuration +└── /mnt/pve/oracle-backups/ [PERMISSIONS] → chmod 777 ``` --- @@ -340,11 +355,120 @@ Get-ScheduledTask | Where-Object {$_.TaskName -like "*Oracle*"} | --- -### PHASE 5: Update DR Restore Script (30 minutes) +### PHASE 5: Configure NFS Mount Point on VM 109 (30 minutes) ✅ COMPLETED -**Objective:** Update restore script to read backups from mount point (E:\) and handle cumulative backups +**Objective:** Mount Proxmox backup storage as F:\ drive in Windows VM using NFS -#### 5.1 Modifică scriptul de restore existent pentru cumulative backups +**Status:** ✅ COMPLETED on 2025-10-10 + +#### 5.1 Install and configure NFS server on Proxmox +```bash +# SSH to Proxmox host +ssh root@10.0.20.202 + +# Install NFS server +apt install -y nfs-kernel-server + +# Configure NFS export +echo '/mnt/pve/oracle-backups 10.0.20.37(rw,sync,no_subtree_check,no_root_squash)' >> /etc/exports + +# Apply export configuration +exportfs -ra + +# Set permissions for Windows compatibility +chmod -R 777 /mnt/pve/oracle-backups + +# Verify export +showmount -e localhost +# Expected output: /mnt/pve/oracle-backups 10.0.20.37 +``` + +#### 5.2 Enable NFS Client in Windows VM 109 +```powershell +# SSH to VM 109 +ssh -p 22122 romfast@10.0.20.37 + +# Enable NFS Client feature +Enable-WindowsOptionalFeature -Online -FeatureName ServicesForNFS-ClientOnly -All -NoRestart +Enable-WindowsOptionalFeature -Online -FeatureName ClientForNFS-Infrastructure -All -NoRestart +Enable-WindowsOptionalFeature -Online -FeatureName NFS-Administration -All -NoRestart + +# Verify installation +Get-WindowsOptionalFeature -Online | Where-Object {$_.FeatureName -like "*NFS*"} +``` + +#### 5.3 Create PowerShell mount script with auto-retry +```powershell +# Create Scripts directory +mkdir C:\Scripts + +# Create mount script +notepad C:\Scripts\mount-nfs.ps1 +``` + +**Content of `C:\Scripts\mount-nfs.ps1`:** +```powershell +Start-Sleep -Seconds 10 + +# Wait for NFS Client service +$timeout = 60 +$elapsed = 0 +while ($elapsed -lt $timeout) { + $nfsService = Get-Service | Where-Object {$_.Name -like "*NFS*" -and $_.Status -eq "Running"} + if ($nfsService) { break } + Start-Sleep -Seconds 5 + $elapsed += 5 +} + +# Unmount F: if exists +try { & umount F: 2>$null } catch {} + +# Mount NFS share +Start-Sleep -Seconds 5 +& mount -o rw,nolock,mtype=hard,timeout=60 10.0.20.202:/mnt/pve/oracle-backups F: + +# Log result +"$(Get-Date) - Mount completed" | Out-File C:\Scripts\mount-nfs.log -Append +``` + +#### 5.4 Create scheduled task for auto-mount at startup +```cmd +# Create scheduled task (run in CMD as Administrator) +schtasks /create /tn "Mount NFS F" /tr "powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\mount-nfs.ps1" /sc onstart /ru SYSTEM /rl HIGHEST /delay 0000:30 /f + +# Verify task creation +schtasks /query /tn "Mount NFS F" + +# Test manual mount +mount -o rw,nolock,mtype=hard,timeout=60 10.0.20.202:/mnt/pve/oracle-backups F: + +# Verify mount +dir F:\ROA\autobackup +``` + +#### 5.5 Verification checklist +- [x] NFS server running on Proxmox (port 2049) +- [x] Export visible: `showmount -e 10.0.20.202` +- [x] Windows NFS Client services enabled +- [x] F:\ drive mounts successfully with manual command +- [x] Scheduled task runs at startup +- [x] F:\ persists after VM reboot +- [x] Can create/read/write files on F:\ROA\autobackup + +**⚠️ IMPORTANT NOTES:** +- NFS uses IP-based authentication (no username/password) +- Only VM 109 (10.0.20.37) can access the share +- `no_root_squash` allows Windows to write as root +- Permissions 777 on Proxmox ensure Windows compatibility +- Mount point is **F:\** (not E:\, which is already in use) + +--- + +### PHASE 6: Update DR Restore Script (30 minutes) + +**Objective:** Update restore script to read backups from F:\ mount point and handle cumulative backups + +#### 6.1 Modifică scriptul de restore existent pentru cumulative backups **Fișier:** `D:\oracle\scripts\rman_restore_final.cmd` (scriptul tău existent) **Modificări necesare:** @@ -493,11 +617,11 @@ exit /b 0 --- -### PHASE 6: Weekly Test Procedure (1 hour first time, 30 min ongoing) +### PHASE 7: Weekly Test Procedure (1 hour first time, 30 min ongoing) **Objective:** Document weekly test procedure using new cumulative backup strategy -#### 6.1 Test procedure (run on Saturday morning) +#### 7.1 Test procedure (run on Saturday morning) ```bash # On Linux workstation or any machine with SSH to Proxmox @@ -543,7 +667,7 @@ ssh root@10.0.20.202 "qm shutdown 109" ssh root@10.0.20.202 "qm status 109" ``` -#### 6.2 Create automated test script +#### 7.2 Create automated test script ```bash #!/bin/bash # File: /root/scripts/test_oracle_dr.sh @@ -669,17 +793,23 @@ Register-ScheduledTask -Xml (Get-Content "D:\rman_backup\backup_tasks\Oracle RMA After completing implementation: -- [ ] Proxmox host directory created: `/mnt/pve/oracle-backups/ROA/autobackup` -- [ ] VM 109 mount point configured and tested (E:\ visible in Windows) -- [ ] RMAN script modified to CUMULATIVE (keyword added) -- [ ] New transfer script created (`02_transfer_to_pveelite_host.ps1`) +- [x] Proxmox host directory created: `/mnt/pve/oracle-backups/ROA/autobackup` +- [x] NFS server installed and configured on Proxmox +- [x] NFS export configured for VM 109 (10.0.20.37) +- [x] NFS Client enabled in Windows VM 109 +- [x] F:\ mount point configured and tested (NFS mount working) +- [x] PowerShell mount script created (`C:\Scripts\mount-nfs.ps1`) +- [x] Scheduled task "Mount NFS F" created for auto-mount at startup +- [x] F:\ drive persists after VM reboot +- [ ] RMAN script modified to CUMULATIVE (keyword added) - **Already has CUMULATIVE** +- [ ] Transfer scripts updated to send to Proxmox host - [ ] SSH key for Proxmox host created and tested -- [ ] Scheduled task created for 13:00 CUMULATIVE backup -- [ ] Scheduled task created for 18:00 CUMULATIVE backup +- [ ] Scheduled task created for 13:00 CUMULATIVE backup on PRIMARY +- [ ] Scheduled task created for 18:00 CUMULATIVE backup on PRIMARY - [ ] Existing 02:30 FULL task updated to use new transfer script - [ ] Manual test of CUMULATIVE backup successful - [ ] Manual test of backup transfer to host successful -- [ ] DR restore script updated (`rman_restore_cumulative.cmd`) +- [ ] DR restore script updated to use F:\ mount - [ ] Full end-to-end restore test successful - [ ] Weekly test script created and tested - [ ] Documentation updated (STATUS and IMPLEMENTATION_PLAN docs) @@ -688,23 +818,37 @@ After completing implementation: ## 📞 NEXT SESSION HANDOFF -**Status:** PLAN COMPLETE - Ready for implementation -**Estimated Implementation Time:** 2-3 hours +**Status:** 🟡 PHASES 1-3-5 COMPLETED - Continue with Phases 4, 6, 7 +**Estimated Remaining Time:** 1.5-2 hours **Recommended Schedule:** Saturday morning (low activity time) **Context for next session:** 1. Primary server: 10.0.20.36 (Windows, Oracle 19c, database ROA) -2. DR VM: 109 on pveelite (10.0.20.37, currently working with FULL-only restore) -3. Proxmox host: pveelite (10.0.20.202) -4. Goal: Implement CUMULATIVE incremental backups (13:00 + 18:00) for better RPO (4-5 hours vs 24 hours) -5. Key change: Backups stored on Proxmox host, mounted in VM 109 when needed +2. DR VM: 109 on pveelite (10.0.20.37, **F:\ NFS mount configured and working** ✅) +3. Proxmox host: pveelite (10.0.20.202, **NFS server running** ✅) +4. Goal: Complete scheduled tasks on PRIMARY + update restore script + test end-to-end +5. **Completed:** Storage setup, NFS mount, transfer scripts to Proxmox -**Start implementation with:** +**What's DONE:** +- ✅ Proxmox host storage (`/mnt/pve/oracle-backups/ROA/autobackup`) +- ✅ NFS server on Proxmox with export for VM 109 +- ✅ NFS Client in Windows VM 109 +- ✅ F:\ drive auto-mounts at startup via scheduled task +- ✅ Transfer scripts modified to send to Proxmox host +- ✅ RMAN script already has CUMULATIVE keyword + +**Next steps to complete:** ```bash -# Phase 1 - Proxmox host storage setup (15 min) -ssh root@10.0.20.202 -mkdir -p /mnt/pve/oracle-backups/ROA/autobackup -# ... follow Phase 1 steps +# Phase 4 - Update scheduled tasks on PRIMARY (45 min) +# 1. Setup SSH key from PRIMARY to Proxmox +# 2. Test transfer scripts +# 3. Create/modify scheduled tasks for 13:00 and 18:00 + +# Phase 6 - Update DR restore script (30 min) +# Modify restore script to use F:\ instead of local path + +# Phase 7 - End-to-end test (30 min) +# Full test: backup → transfer → mount → restore ``` **IMPORTANT - Backup manual înainte de modificări:**