fix: Snapshot-Ausschlussliste (.backupignore) gegen GB-grosse Content-Ordner
This commit is contained in:
+22
-5
@@ -35,14 +35,29 @@ function Start-Portal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Vollständiger Snapshot der Portal-Wurzel als ein ZIP (alles außer .backup + TempUpdate).
|
# Ausschlussliste: immer .backup/TempUpdate, plus Einträge aus .backupignore
|
||||||
# Erfasst ALLE Unterordner inkl. data/ → echtes 1:1, inkl. später gelöschter Dateien.
|
# (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 {
|
function New-Snapshot {
|
||||||
$ts = Get-Date -Format 'yyyyMMdd-HHmmss'
|
$ts = Get-Date -Format 'yyyyMMdd-HHmmss'
|
||||||
$bk = Join-Path $root '.backup'
|
$bk = Join-Path $root '.backup'
|
||||||
if (-not (Test-Path -LiteralPath $bk)) { New-Item -ItemType Directory -Path $bk -Force | Out-Null }
|
if (-not (Test-Path -LiteralPath $bk)) { New-Item -ItemType Directory -Path $bk -Force | Out-Null }
|
||||||
$zip = Join-Path $bk "snapshot-$ts.zip"
|
$zip = Join-Path $bk "snapshot-$ts.zip"
|
||||||
$exclude = @('.backup','TempUpdate')
|
$exclude = Get-ExcludeNames
|
||||||
$items = Get-ChildItem -LiteralPath $root -Force | Where-Object { $exclude -notcontains $_.Name }
|
$items = Get-ChildItem -LiteralPath $root -Force | Where-Object { $exclude -notcontains $_.Name }
|
||||||
if (-not $items) { throw "Portal-Wurzel ist leer — nichts zu sichern." }
|
if (-not $items) { throw "Portal-Wurzel ist leer — nichts zu sichern." }
|
||||||
Compress-Archive -Path $items.FullName -DestinationPath $zip -CompressionLevel Optimal -Force
|
Compress-Archive -Path $items.FullName -DestinationPath $zip -CompressionLevel Optimal -Force
|
||||||
@@ -60,8 +75,10 @@ function New-Snapshot {
|
|||||||
|
|
||||||
function Restore-Snapshot {
|
function Restore-Snapshot {
|
||||||
param([string]$Zip)
|
param([string]$Zip)
|
||||||
# Wurzel leeren (außer .backup), dann Snapshot zurückspielen
|
# Wurzel leeren (außer .backup + .backupignore-Ordner), dann Snapshot zurückspielen.
|
||||||
Get-ChildItem -LiteralPath $root -Force | Where-Object { $_.Name -ne '.backup' } |
|
# 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
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
Expand-Archive -LiteralPath $Zip -DestinationPath $root -Force
|
Expand-Archive -LiteralPath $Zip -DestinationPath $root -Force
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user