fix: Rollback beachtet .backupignore (Content-Ordner unangetastet)

This commit is contained in:
Rhino
2026-06-20 21:50:46 +02:00
parent b25354723e
commit 7bdb0b0c13
+12 -2
View File
@@ -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