Update Oracle 18c/21c export scripts and documentation

- Increase LXC 108 memory from 4GB to 8GB + 2GB swap
- Add manual startup/shutdown instructions for Oracle containers
- Document CDB/PDB architecture and correct connection strings
- Fix export-roa2.sh: use XEPDB1 PDB for Oracle 18c, separate DMPDIR
- Fix export-roa2.ps1: dual DMPDIR paths, auto-start containers
- Add container/database status checks before export
- Add TNS entries with SERVICE_NAME=XEPDB1 (not SID=XE)
- Document DBMS_CUBE_EXP warnings as harmless

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Marius
2026-01-27 23:42:34 +02:00
parent 7c6e54f018
commit d2b24c1c47
5 changed files with 441 additions and 652 deletions

View File

@@ -3,7 +3,8 @@
$BackupDir = "E:\backups\oracle"
$Proxmox = "root@10.0.20.201"
$DmpDir = "/opt/oracle/oradata/dmpdir"
$DmpDir21 = "/opt/oracle/oradata/dmpdir" # Oracle 21c
$DmpDir18 = "/opt/oracle18/oradata/dmpdir" # Oracle 18c
# Creează directorul backup dacă nu există
if (!(Test-Path $BackupDir)) {
@@ -11,7 +12,16 @@ if (!(Test-Path $BackupDir)) {
}
function Get-RemoteArchives {
$result = ssh $Proxmox "pct exec 108 -- bash -c 'ls -lt $DmpDir/*.tar.gz 2>/dev/null'" 2>$null
param([string]$DmpDir = "")
# Dacă nu e specificat, caută în ambele directoare
if ([string]::IsNullOrEmpty($DmpDir)) {
$dirs = "$DmpDir18 $DmpDir21"
} else {
$dirs = $DmpDir
}
$result = ssh $Proxmox "pct exec 108 -- bash -c 'for d in $dirs; do ls -lt `$d/*.tar.gz 2>/dev/null; done'" 2>$null
if ($result) {
$archives = @()
foreach ($line in $result) {
@@ -42,6 +52,25 @@ function Copy-Archive($archivePath) {
Write-Host " Done" -ForegroundColor Green
}
function Start-OracleContainer {
param([string]$Container)
Write-Host "Pornesc containerul $Container..." -ForegroundColor Yellow
ssh $Proxmox "pct exec 108 -- docker start $Container"
Write-Host "Astept 60s pentru startup Oracle..." -ForegroundColor Yellow
Start-Sleep -Seconds 60
# Verifică dacă e pornit
$status = ssh $Proxmox "pct exec 108 -- docker ps --format '{{.Names}}' | grep $Container"
if ($status) {
Write-Host "Container $Container pornit cu succes!" -ForegroundColor Green
return $true
} else {
Write-Host "EROARE: Container $Container nu a pornit!" -ForegroundColor Red
return $false
}
}
function Run-Export {
Write-Host "`nSelecteaza sursa Oracle:" -ForegroundColor Cyan
Write-Host " 1. Oracle 18c (port 1522) - Compatibil 11g/18c/19c (Recomandat)"
@@ -49,8 +78,52 @@ function Run-Export {
$srcChoice = Read-Host "Selecteaza sursa [1]"
$oracleVer = switch ($srcChoice) {
'2' { '21' }
default { '18' }
'2' { '21'; $containerName = 'oracle-xe' }
default { '18'; $containerName = 'oracle18-xe' }
}
if ($oracleVer -eq '18') {
$containerName = 'oracle18-xe'
$currentDmpDir = $DmpDir18
} else {
$containerName = 'oracle-xe'
$currentDmpDir = $DmpDir21
}
# Verifică dacă LXC 108 rulează
Write-Host "`nVerific LXC 108..." -NoNewline
$lxcStatus = ssh $Proxmox "pct status 108" 2>$null
if ($lxcStatus -notmatch "running") {
Write-Host " OPRIT" -ForegroundColor Red
$start = Read-Host "Pornesc LXC 108? (D/n)"
if ($start -ne 'n') {
Write-Host "Pornesc LXC 108..." -ForegroundColor Yellow
ssh $Proxmox "pct start 108"
Start-Sleep -Seconds 10
} else {
Write-Host "Anulat." -ForegroundColor Gray
return
}
} else {
Write-Host " OK" -ForegroundColor Green
}
# Verifică dacă containerul Oracle rulează
Write-Host "Verific container $containerName..." -NoNewline
$containerStatus = ssh $Proxmox "pct exec 108 -- docker ps --format '{{.Names}}' | grep $containerName" 2>$null
if (-not $containerStatus) {
Write-Host " OPRIT" -ForegroundColor Red
$start = Read-Host "Pornesc $containerName? (D/n)"
if ($start -ne 'n') {
if (-not (Start-OracleContainer -Container $containerName)) {
return
}
} else {
Write-Host "Anulat." -ForegroundColor Gray
return
}
} else {
Write-Host " OK" -ForegroundColor Green
}
if ($oracleVer -eq '18') {
@@ -61,9 +134,9 @@ function Run-Export {
ssh $Proxmox "pct exec 108 -- bash /opt/oracle/oradata/export-roa2.sh $oracleVer"
# Copiază cele mai noi 2 arhive
# Copiază cele mai noi 2 arhive din directorul corect
Write-Host "`nCopying new archives..." -ForegroundColor Yellow
$archives = Get-RemoteArchives | Select-Object -First 2
$archives = Get-RemoteArchives -DmpDir $currentDmpDir | Select-Object -First 2
foreach ($archive in $archives) {
Copy-Archive $archive.Path
}