od-db-backup: clarify full backup = DB + images (app is reinstalled), capture config + versions

Per Open Dental docs a complete backup is the database + A-to-Z images; the
program itself is not backed up but reinstalled at the matching version on
restore. Extend the script to capture two recovery aids best-effort (outside
the downtime window): a copy of FreeDentalConfig.xml and the exact Open Dental
+ MySQL/MariaDB versions, recorded in MANIFEST.txt. Runbook now spells out
what is/isn't backed up and notes the config file holds the obfuscated DB
password on direct-connect setups.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-12 23:21:17 -07:00
parent 5dfa62ced6
commit 25a5127d53
2 changed files with 56 additions and 15 deletions
+40 -8
View File
@@ -206,21 +206,53 @@ finally {
}
}
# --- 9. Write a manifest and report ---
# --- 9. Capture recovery aids: FreeDentalConfig.xml + version stamps (best-effort) ---
# The Open Dental program is NOT backed up (reinstall the matching version on
# restore). But grabbing the connection config and recording the exact versions
# makes a restore fast and version-correct. Best-effort: never fails the backup.
if ($ok) {
$odInstall = @(${env:ProgramFiles(x86)}, $env:ProgramFiles) | Where-Object { $_ } |
ForEach-Object { Join-Path $_ 'Open Dental' } |
Where-Object { Test-Path $_ } | Select-Object -First 1
$odVersion = 'unknown'
if ($odInstall) {
$cfg = Join-Path $odInstall 'FreeDentalConfig.xml'
if (Test-Path $cfg) {
try { Copy-Item -LiteralPath $cfg -Destination (Join-Path $backupDir 'FreeDentalConfig.xml') -Force
Log 'Captured FreeDentalConfig.xml (connection/AtoZ config).' }
catch { Log "Could not copy FreeDentalConfig.xml: $($_.Exception.Message)" }
}
$exe = Join-Path $odInstall 'OpenDental.exe'
if (Test-Path $exe) { try { $odVersion = (Get-Item $exe).VersionInfo.FileVersion } catch {} }
}
# DB engine version from the service's backing executable
$dbVersion = 'unknown'
try {
$imgPath = (Get-CimInstance Win32_Service -Filter "Name='$svcName'" -ErrorAction Stop).PathName
$exePath = ([regex]::Match($imgPath, '([A-Za-z]:\\[^"]*?\.exe)')).Groups[1].Value
if ($exePath -and (Test-Path $exePath)) { $dbVersion = (Get-Item $exePath).VersionInfo.ProductVersion }
} catch {}
}
# --- 10. Write a manifest and report ---
if ($ok) {
$manifest = @"
Open Dental cold backup
Created : $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')
Host : $env:COMPUTERNAME
Service : $svcName
Data directory : $dataDir (~$dataGB GB)
Images folder : $(if($imgDir){"$imgDir (~$imgGB GB)"}else{'(skipped)'})
Backup folder : $backupDir
Method : cold copy (service stopped + verified), whole data dir incl InnoDB shared tablespace/logs
Created : $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')
Host : $env:COMPUTERNAME
Service : $svcName
Open Dental ver : $odVersion (reinstall THIS version to restore)
DB engine ver : $dbVersion (restore onto a matching MySQL/MariaDB)
Data directory : $dataDir (~$dataGB GB)
Images folder : $(if($imgDir){"$imgDir (~$imgGB GB)"}else{'(skipped)'})
FreeDentalConfig : $(if($odInstall -and (Test-Path (Join-Path $backupDir 'FreeDentalConfig.xml'))){'captured'}else{'(not found)'})
Backup folder : $backupDir
Method : cold copy (service stopped + verified), whole data dir incl InnoDB shared tablespace/logs
"@
Set-Content -LiteralPath (Join-Path $backupDir 'MANIFEST.txt') -Value $manifest
Write-Host ''
Write-Host "Backup complete: $backupDir" -ForegroundColor Green
Write-Host "Open Dental $odVersion / DB $dbVersion — reinstall matching versions to restore." -ForegroundColor Green
Write-Host 'Next: copy this folder OFF-SITE, and TEST-RESTORE it periodically on an isolated machine.' -ForegroundColor Green
Write-Host 'Never restore over a live production database.' -ForegroundColor Yellow
}