From 7bdb0b0c13d44a924383f3f4f1ad5d44d192fd48 Mon Sep 17 00:00:00 2001 From: Rhino <1+rhino@noreply.gitea.rhino.nrw> Date: Sat, 20 Jun 2026 21:50:46 +0200 Subject: [PATCH] fix: Rollback beachtet .backupignore (Content-Ordner unangetastet) --- scripts/rollback.ps1 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/rollback.ps1 b/scripts/rollback.ps1 index debcf1f..75e6350 100644 --- a/scripts/rollback.ps1 +++ b/scripts/rollback.ps1 @@ -2,12 +2,22 @@ # Kanonisches Rollback-Skript (Referenz). Die ausgelieferte rollback.bat enthaelt # diese Logik EINGEBETTET und laeuft damit vollstaendig OFFLINE (kein Netz noetig). # Erwartet im aufrufenden Scope: $root, $stopBat, $startBat +# Beachtet .backupignore (grosse Content-Ordner, die nie veraendert werden). $ErrorActionPreference = 'Stop' # Erwartet im Scope: $root, $stopBat, $startBat $_stopName = if ($null -ne $stopBat) { $stopBat } else { 'stop.bat' } $_startName = if ($null -ne $startBat) { $startBat } else { 'dgl.bat' } +# Ausschlussliste (identisch zu update.ps1): .backup nie anfassen, plus große +# Content-Ordner aus .backupignore — diese bleiben beim Rollback unverändert. +$_excl = @('.backup') +$_ignoreFile = Join-Path $root '.backupignore' +if (Test-Path -LiteralPath $_ignoreFile) { + $_excl += (Get-Content -LiteralPath $_ignoreFile | ForEach-Object { $_.Trim() } | + Where-Object { $_ -ne '' -and -not $_.StartsWith('#') }) +} + $bk = Join-Path $root '.backup' if (-not (Test-Path -LiteralPath $bk)) { Write-Host "Kein Backup-Verzeichnis gefunden. Sicherungen entstehen automatisch beim ersten Update." -ForegroundColor Red @@ -64,7 +74,7 @@ if ($_stopName -ne '') { # Aktuellen Stand beiseite verschieben (Sicherheitsnetz, kein Datenverlust) $aside = Join-Path $bk ("_vor-rollback-" + (Get-Date -Format 'yyyyMMdd-HHmmss')) New-Item -ItemType Directory -Path $aside -Force | Out-Null -Get-ChildItem -LiteralPath $root -Force | Where-Object { $_.Name -ne '.backup' } | ForEach-Object { +Get-ChildItem -LiteralPath $root -Force | Where-Object { $_excl -notcontains $_.Name } | ForEach-Object { Move-Item -LiteralPath $_.FullName -Destination (Join-Path $aside $_.Name) -Force } @@ -74,7 +84,7 @@ try { Write-Host "Stand wiederhergestellt: $($chosen.Name)" -ForegroundColor Green } catch { Write-Host "FEHLER beim Wiederherstellen — mache Änderung rückgängig ..." -ForegroundColor Red - Get-ChildItem -LiteralPath $root -Force | Where-Object { $_.Name -ne '.backup' } | + Get-ChildItem -LiteralPath $root -Force | Where-Object { $_excl -notcontains $_.Name } | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue Get-ChildItem -LiteralPath $aside -Force | ForEach-Object { Move-Item -LiteralPath $_.FullName -Destination (Join-Path $root $_.Name) -Force