main init

This commit is contained in:
2026-11-13 00:38:47 +01:00
commit e377873a85
124 changed files with 12320 additions and 0 deletions

25
Backup/backup-config.json Normal file
View File

@@ -0,0 +1,25 @@
{
"source": "D:\\Oculusquest\\Projekt",
"target": "\\\\MYCLOUD-NESYFV\\Michael\\Projekte",
"targets": [
{
"id": "q2jr36mi",
"name": "MYCLOUD-NESYFV",
"path": "\\\\MYCLOUD-NESYFV\\Michael\\Projekte"
}
],
"excludeDirs": [
"node_modules",
"__pycache__",
".gradle",
".venv",
"venv",
".venv-tts",
".bin"
],
"excludeFiles": [
"Thumbs.db",
"desktop.ini",
"~$*"
]
}

View File

@@ -0,0 +1,27 @@
@echo off
rem ============================================================================
rem Backup D:\Oculusquest\Projekt -> \\MYCLOUD-NESYFV\Michael\Projekte
rem
rem 1. prueft, was neu/geaendert ist und im Backup fehlt (Anzahl, Groesse, pro Projekt)
rem 2. fragt nach und kopiert genau das
rem
rem Im Backup wird NIE etwas geloescht. Dateien, die es hier nicht mehr gibt,
rem werden nur angezeigt und bleiben im Backup erhalten.
rem
rem Nicht gesichert (wird neu erzeugt): node_modules, __pycache__, .gradle, .venv, venv, .venv-tts
rem
rem Aufruf:
rem backup-projekte.bat pruefen, nachfragen, kopieren
rem backup-projekte.bat test nur pruefen
rem backup-projekte.bat auto pruefen + kopieren ohne Nachfrage (Aufgabenplanung)
rem
rem Logik: backup-projekte.ps1 · Protokolle: logs\pruefung-*.log, logs\backup-*.log
rem ============================================================================
setlocal enabledelayedexpansion
set "ARGS="
for %%a in (%*) do (
if /i "%%~a"=="test" set "ARGS=!ARGS! -Test"
if /i "%%~a"=="auto" set "ARGS=!ARGS! -Auto"
)
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0backup-projekte.ps1" !ARGS!
exit /b %ERRORLEVEL%

132
Backup/backup-projekte.ps1 Normal file
View File

@@ -0,0 +1,132 @@
<#
.SYNOPSIS
Backup D:\Oculusquest\Projekt -> \\MYCLOUD-NESYFV\Michael\Projekte, in two steps:
1. check: which files are new/changed (missing or outdated in the backup)
2. copy exactly those (after asking, unless -Auto)
Nothing is ever deleted in the backup. Files that exist only in the backup
(deleted or renamed locally) are listed and kept.
Not backed up (regenerable): node_modules, __pycache__, .gradle, .venv, venv, .venv-tts
.EXAMPLE
.\backup-projekte.ps1 check, ask, copy
.\backup-projekte.ps1 -Test only check
.\backup-projekte.ps1 -Auto check and copy without asking (task scheduler)
#>
param(
[string]$Source,
[string]$Target,
[switch]$Test,
[switch]$Auto
)
$ErrorActionPreference = 'Stop'
# Same settings as the backup in the project dashboard: backup-config.json
$cfg = Get-Content (Join-Path $PSScriptRoot 'backup-config.json') -Raw -Encoding UTF8 | ConvertFrom-Json
if (-not $Source) { $Source = $cfg.source }
if (-not $Target) { $Target = $cfg.target }
$logDir = Join-Path $PSScriptRoot 'logs'
New-Item -ItemType Directory -Force $logDir | Out-Null
$stamp = Get-Date -Format 'yyyy-MM-dd_HH-mm'
$checkLog = Join-Path $logDir "pruefung-$stamp.log"
$copyLog = Join-Path $logDir "backup-$stamp.log"
$common = @('/E', '/FFT', '/XJ', '/R:2', '/W:5', '/COPY:DAT', '/DCOPY:T', '/XD') + @($cfg.excludeDirs) + @('/XF') + @($cfg.excludeFiles)
# /FFT: NAS timestamps have 2 s precision - without it every file would look changed
function Format-Size([double]$b) {
if ($b -ge 1GB) { return ('{0:N1} GB' -f ($b / 1GB)) }
if ($b -ge 1MB) { return ('{0:N0} MB' -f ($b / 1MB)) }
return ('{0:N0} KB' -f ($b / 1KB))
}
function Stop-Here([int]$code) {
if (-not $Auto) { Write-Host ''; Read-Host 'Enter zum Schliessen' | Out-Null }
exit $code
}
Write-Host ''
Write-Host " Backup: $Source" -ForegroundColor Cyan
Write-Host " nach: $Target" -ForegroundColor Cyan
Write-Host ''
if (-not (Test-Path -LiteralPath $Source)) { Write-Host " FEHLER: Quelle $Source fehlt." -ForegroundColor Red; Stop-Here 1 }
if (-not (Test-Path -LiteralPath $Target)) {
$share = Split-Path $Target -Parent
if (-not (Test-Path -LiteralPath $share)) {
Write-Host " FEHLER: MyCloud nicht erreichbar ($share). Eingeschaltet und im Netzwerk?" -ForegroundColor Red
Stop-Here 1
}
New-Item -ItemType Directory $Target | Out-Null
}
# ── 1. check ───────────────────────────────────────────────────────────────
Write-Host ' 1/2 Pruefe, was neu ist und im Backup fehlt ...' -ForegroundColor Yellow
# /L = list only, /X = also report files that exist only in the backup
& robocopy $Source $Target @common /L /X /NJH /NJS /NDL /NP /FP /BYTES /UNILOG:$checkLog | Out-Null
if ($LASTEXITCODE -ge 8) { Write-Host " FEHLER bei der Pruefung (robocopy $LASTEXITCODE). Details: $checkLog" -ForegroundColor Red; Stop-Here 1 }
$copy = New-Object System.Collections.Generic.List[object]
$extra = New-Object System.Collections.Generic.List[object]
foreach ($line in [IO.File]::ReadAllLines($checkLog)) {
$parts = $line.Split("`t") | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' }
if ($parts.Count -lt 3) { continue }
$path = $parts[-1]; $size = 0
if (-not [int64]::TryParse($parts[-2], [ref]$size)) { continue }
$isExtra = $parts[0] -like '*EXTRA*'
$base = if ($isExtra) { $Target } else { $Source }
if (-not $path.StartsWith($base, [StringComparison]::OrdinalIgnoreCase)) { continue }
$rel = $path.Substring($base.Length).TrimStart('\')
# robocopy's class column: "Neue Datei"/"New File" = missing in the backup, otherwise newer/changed
$item = [pscustomobject]@{ Project = ($rel -split '\\')[0]; Rel = $rel; Size = $size; New = $parts[0] -match '^(Neue Datei|New File)$' }
if ($isExtra) { $extra.Add($item) } else { $copy.Add($item) }
}
$newFiles = @($copy | Where-Object New)
$changed = @($copy | Where-Object { -not $_.New })
$total = ($copy | Measure-Object Size -Sum).Sum
Write-Host ''
if ($copy.Count -eq 0) {
Write-Host ' Alles aktuell - im Backup fehlt nichts.' -ForegroundColor Green
} else {
Write-Host (" Zu kopieren: {0:N0} Dateien, {1}" -f $copy.Count, (Format-Size $total)) -ForegroundColor White
Write-Host (" neu (fehlen im Backup): {0,8:N0} {1}" -f $newFiles.Count, (Format-Size (($newFiles | Measure-Object Size -Sum).Sum)))
Write-Host (" geaendert: {0,8:N0} {1}" -f $changed.Count, (Format-Size (($changed | Measure-Object Size -Sum).Sum)))
Write-Host ''
Write-Host ' Nach Projekt:'
$copy | Group-Object Project | ForEach-Object {
[pscustomobject]@{ Name = $_.Name; Files = $_.Count; Bytes = ($_.Group | Measure-Object Size -Sum).Sum }
} | Sort-Object Bytes -Descending | Select-Object -First 15 | ForEach-Object {
Write-Host (" {0,-28} {1,8:N0} Dateien {2,10}" -f $_.Name, $_.Files, (Format-Size $_.Bytes))
}
}
if ($extra.Count) {
Write-Host ''
Write-Host (" Nur noch im Backup (hier geloescht/umbenannt): {0:N0} Dateien, {1} - bleiben erhalten." -f $extra.Count, (Format-Size (($extra | Measure-Object Size -Sum).Sum))) -ForegroundColor DarkGray
}
Write-Host ''
Write-Host " Vollstaendige Liste: $checkLog" -ForegroundColor DarkGray
if ($copy.Count -eq 0) { Stop-Here 0 }
if ($Test) { Write-Host ''; Write-Host ' Testlauf - es wurde nichts kopiert.' -ForegroundColor Yellow; Stop-Here 0 }
if (-not $Auto) {
Write-Host ''
$answer = Read-Host ' Jetzt kopieren? (J/N)'
if ($answer -notmatch '^(j|ja|y|yes)$') { Write-Host ' Abgebrochen, nichts kopiert.'; Stop-Here 0 }
}
# ── 2. copy ────────────────────────────────────────────────────────────────
Write-Host ''
Write-Host ' 2/2 Kopiere neue und geaenderte Dateien ...' -ForegroundColor Yellow
& robocopy $Source $Target @common /MT:16 /NDL /NP /TEE /UNILOG:$copyLog
$rc = $LASTEXITCODE
Write-Host ''
if ($rc -ge 8) {
Write-Host " FEHLER: Backup unvollstaendig (robocopy $rc). Details: $copyLog" -ForegroundColor Red
Stop-Here 1
}
Write-Host (" Backup fertig: {0:N0} Dateien, {1}. Protokoll: {2}" -f $copy.Count, (Format-Size $total), $copyLog) -ForegroundColor Green
Stop-Here 0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@