fix: Rollback beachtet .backupignore (Content-Ordner unangetastet)
This commit is contained in:
+12
-2
@@ -2,12 +2,22 @@
|
|||||||
# Kanonisches Rollback-Skript (Referenz). Die ausgelieferte rollback.bat enthaelt
|
# Kanonisches Rollback-Skript (Referenz). Die ausgelieferte rollback.bat enthaelt
|
||||||
# diese Logik EINGEBETTET und laeuft damit vollstaendig OFFLINE (kein Netz noetig).
|
# diese Logik EINGEBETTET und laeuft damit vollstaendig OFFLINE (kein Netz noetig).
|
||||||
# Erwartet im aufrufenden Scope: $root, $stopBat, $startBat
|
# Erwartet im aufrufenden Scope: $root, $stopBat, $startBat
|
||||||
|
# Beachtet .backupignore (grosse Content-Ordner, die nie veraendert werden).
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
# Erwartet im Scope: $root, $stopBat, $startBat
|
# Erwartet im Scope: $root, $stopBat, $startBat
|
||||||
$_stopName = if ($null -ne $stopBat) { $stopBat } else { 'stop.bat' }
|
$_stopName = if ($null -ne $stopBat) { $stopBat } else { 'stop.bat' }
|
||||||
$_startName = if ($null -ne $startBat) { $startBat } else { 'dgl.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'
|
$bk = Join-Path $root '.backup'
|
||||||
if (-not (Test-Path -LiteralPath $bk)) {
|
if (-not (Test-Path -LiteralPath $bk)) {
|
||||||
Write-Host "Kein Backup-Verzeichnis gefunden. Sicherungen entstehen automatisch beim ersten Update." -ForegroundColor Red
|
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)
|
# Aktuellen Stand beiseite verschieben (Sicherheitsnetz, kein Datenverlust)
|
||||||
$aside = Join-Path $bk ("_vor-rollback-" + (Get-Date -Format 'yyyyMMdd-HHmmss'))
|
$aside = Join-Path $bk ("_vor-rollback-" + (Get-Date -Format 'yyyyMMdd-HHmmss'))
|
||||||
New-Item -ItemType Directory -Path $aside -Force | Out-Null
|
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
|
Move-Item -LiteralPath $_.FullName -Destination (Join-Path $aside $_.Name) -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +84,7 @@ try {
|
|||||||
Write-Host "Stand wiederhergestellt: $($chosen.Name)" -ForegroundColor Green
|
Write-Host "Stand wiederhergestellt: $($chosen.Name)" -ForegroundColor Green
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "FEHLER beim Wiederherstellen — mache Änderung rückgängig ..." -ForegroundColor Red
|
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
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
Get-ChildItem -LiteralPath $aside -Force | ForEach-Object {
|
Get-ChildItem -LiteralPath $aside -Force | ForEach-Object {
|
||||||
Move-Item -LiteralPath $_.FullName -Destination (Join-Path $root $_.Name) -Force
|
Move-Item -LiteralPath $_.FullName -Destination (Join-Path $root $_.Name) -Force
|
||||||
|
|||||||
Reference in New Issue
Block a user