Compare commits

..

2 Commits

Author SHA1 Message Date
jamesp de47f41fc3 Increase CleanupTime to 48 2026-06-24 14:52:29 +01:00
jamesp bbbc824916 Improve LSN gap check 2026-06-24 14:49:18 +01:00
2 changed files with 20 additions and 3 deletions
+18 -1
View File
@@ -577,7 +577,24 @@ function Print-BackupSummary {
Write-Host " Point-in-Time Range: $(([datetime]$firstLog.BackupStartDate).ToString([System.Globalization.CultureInfo]::CurrentCulture)) to $(([datetime]$lastLog.BackupFinishDate).ToString([System.Globalization.CultureInfo]::CurrentCulture))"
Write-Host " LSN Range: $($firstLog.FirstLSN) - $($lastLog.LastLSN)"
# Check for gaps
# Check that the first LOG connects to the most recent FULL (or DIFF if one exists).
$baseLastLsn = $null
$baseLabel = $null
if ($Headers.ContainsKey('DIFF') -and $Headers['DIFF'].Count -gt 0) {
$latestDiff = @($Headers['DIFF'] | Sort-Object { $_.Key })[-1]
$dh = @($latestDiff.Header)[0]
if ($dh) { $baseLastLsn = $dh.LastLSN; $baseLabel = "DIFF $($latestDiff.Key)" }
}
if (-not $baseLastLsn -and $Headers.ContainsKey('FULL') -and $Headers['FULL'].Count -gt 0) {
$latestFull = @($Headers['FULL'] | Sort-Object { $_.Key })[-1]
$fh = @($latestFull.Header)[0]
if ($fh) { $baseLastLsn = $fh.LastLSN; $baseLabel = "FULL $($latestFull.Key)" }
}
if ($baseLastLsn -and [decimal]$firstLog.FirstLSN -gt [decimal]$baseLastLsn) {
Write-Host " *** LSN GAP: first LOG (LSN $($firstLog.FirstLSN)) does not connect to $baseLabel (ends LSN $baseLastLsn) — point-in-time restore will fail ***"
}
# Check for gaps within the LOG sequence
$gaps = @()
for ($i = 1; $i -lt $logItems.Count; $i++) {
$prevHeader = @($logItems[$i-1].Header)[0]
+2 -2
View File
@@ -532,7 +532,7 @@ function Get-BackupType($directoryParam) {
$reason = if ($isFullBackupOverdue) { "overdue" } else { "scheduled" }
return @{ Type = "FULL"; CleanupTime = 168; Reason = $reason }
} else {
return @{ Type = "LOG"; CleanupTime = 24; Reason = "full already taken today" }
return @{ Type = "LOG"; CleanupTime = 48; Reason = "full already taken today" }
}
}
@@ -563,7 +563,7 @@ function Get-BackupType($directoryParam) {
}
return @{ Type = "DIFF"; CleanupTime = 168; Reason = "differential scheduled" }
} else {
return @{ Type = "LOG"; CleanupTime = 24; Reason = "diff already taken today" }
return @{ Type = "LOG"; CleanupTime = 48; Reason = "diff already taken today" }
}
}