fix: Snapshot-Ausschlussliste (.backupignore) gegen GB-grosse Content-Ordner

This commit is contained in:
Rhino
2026-06-20 21:50:46 +02:00
parent 64d30948b0
commit b25354723e
+22 -5
View File
@@ -35,14 +35,29 @@ function Start-Portal {
}
}
# Vollständiger Snapshot der Portal-Wurzel als ein ZIP (alles außer .backup + TempUpdate).
# Erfasst ALLE Unterordner inkl. data/ → echtes 1:1, inkl. später gelöschter Dateien.
# Ausschlussliste: immer .backup/TempUpdate, plus Einträge aus .backupignore
# (große, von Updates NIE berührte Content-Ordner, z.B. _archiv/dokumente).
# Ausgeschlossene Ordner werden weder gesichert noch beim Rollback verändert.
function Get-ExcludeNames {
param([switch]$ForWipe)
$ex = if ($ForWipe) { @('.backup') } else { @('.backup','TempUpdate') }
$f = Join-Path $root '.backupignore'
if (Test-Path -LiteralPath $f) {
$ex += (Get-Content -LiteralPath $f | ForEach-Object { $_.Trim() } |
Where-Object { $_ -ne '' -and -not $_.StartsWith('#') })
}
return $ex
}
# Vollständiger Snapshot der Portal-Wurzel als ein ZIP (außer .backup/TempUpdate
# und .backupignore-Einträgen). Erfasst alle Code-Unterordner inkl. data/
# → echtes 1:1 des veränderbaren Stands, inkl. später gelöschter Dateien.
function New-Snapshot {
$ts = Get-Date -Format 'yyyyMMdd-HHmmss'
$bk = Join-Path $root '.backup'
if (-not (Test-Path -LiteralPath $bk)) { New-Item -ItemType Directory -Path $bk -Force | Out-Null }
$zip = Join-Path $bk "snapshot-$ts.zip"
$exclude = @('.backup','TempUpdate')
$exclude = Get-ExcludeNames
$items = Get-ChildItem -LiteralPath $root -Force | Where-Object { $exclude -notcontains $_.Name }
if (-not $items) { throw "Portal-Wurzel ist leer — nichts zu sichern." }
Compress-Archive -Path $items.FullName -DestinationPath $zip -CompressionLevel Optimal -Force
@@ -60,8 +75,10 @@ function New-Snapshot {
function Restore-Snapshot {
param([string]$Zip)
# Wurzel leeren (außer .backup), dann Snapshot zurückspielen
Get-ChildItem -LiteralPath $root -Force | Where-Object { $_.Name -ne '.backup' } |
# Wurzel leeren (außer .backup + .backupignore-Ordner), dann Snapshot zurückspielen.
# Ausgeschlossene Content-Ordner bleiben unangetastet an Ort und Stelle.
$ex = Get-ExcludeNames -ForWipe
Get-ChildItem -LiteralPath $root -Force | Where-Object { $ex -notcontains $_.Name } |
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
Expand-Archive -LiteralPath $Zip -DestinationPath $root -Force
}