# Production example: use only after a small test passes.
& {
  $ErrorActionPreference = 'Stop'
  $dataDir = 'D:\FRAME'
  $configDir = Join-Path $env:USERPROFILE 'AI_Studio'
  $repo = 'E:\FRAME_BACKUP'
  foreach ($path in @($dataDir, $configDir, "$repo\config")) {
    if (!(Test-Path -LiteralPath $path)) { throw "Missing: $path" }
  }
  $cacheDir = Join-Path $dataDir '90_CACHE'
  & restic.exe -r $repo backup $dataDir $configDir `
    --exclude $cacheDir --exclude '**/.venv'
  if ($LASTEXITCODE -ne 0) { throw 'Backup is incomplete.' }
  & restic.exe -r $repo snapshots
  if ($LASTEXITCODE -ne 0) { throw 'Snapshot listing failed.' }
}
