Files
vitya 73ad6dd06a scripts(backup-notifications): unify push + email format across VDS/RUVDS/windows-host
3 host-pipelines (VDS bash, RUVDS+windows-host ps1) had drifted formats:
ntfy title `VDS backup OK $D` vs `RUVDS backup OK ($D)`, tags
`white_check_mark` vs `green_circle`, email subject `[VDS] backup OK` vs
`RUVDS backup -- SUCCESS`. Phone-side фильтрация и desktop reading
ломались за счёт inconsistency.

Unified to:
- ntfy push: title `<HOST> backup OK <date>`, body
  `<duration_human>, size=<>, snapshots=<>, dest=kreknin:<>`,
  tags `green_circle` (OK) / `red_circle` (FAILED).
- email: subject `[<HOST>] backup <STATUS> <date>` (STATUS=OK|FAILED),
  body — structured Date/Duration/Size/Snapshots/Source/Dest/Components/Log.
  Failure body extends with `Tail (last 40 lines)`.

Also imports VDS `run.sh` into repo as `scripts/vds-backup-rsync-kreknin/`
— closes drift из общего `scripts/<slug>/` pattern (RUVDS+windows-host
уже жили там; VDS жил только на /opt/stacks/backup/scripts/).

Deploy status:
- VDS: deployed via scp + sudo install, sha256=27b09ca272bb, smoke ntfy+email ✓
- RUVDS: deployed via scp + Move-Item, sha256=f3bb57a86af5, smoke ntfy+email ✓
- windows-host: deploy.ps1 + smoke-notify.ps1 готовы в scripts/, **pending
  elevated PS у user'а** (ACL=SYSTEM+Administrators, не пишется без UAC).

Spec + decisions + completed: .tasks/unify-backup-notifications.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 07:19:15 +03:00

28 lines
1.1 KiB
PowerShell

# Deploy local repo run.ps1 -> C:\ProgramData\backup\run.ps1 with .bak rollback.
# MUST be run elevated (ProgramData ACL = SYSTEM + Administrators).
# Usage: open elevated PowerShell, cd to repo root, then: & .\scripts\windows-host-fallback-backup-daily\deploy.ps1
$ErrorActionPreference = 'Stop'
$repoSrc = Join-Path $PSScriptRoot 'run.ps1'
$dst = 'C:\ProgramData\backup\run.ps1'
$bak = "$dst.bak-pre-unify"
if (-not (Test-Path $repoSrc)) { throw "source missing: $repoSrc" }
if (-not (Test-Path $dst)) { throw "destination missing: $dst (windows-host backup not initialized?)" }
# Backup current (if no pre-unify backup yet)
if (-not (Test-Path $bak)) {
Copy-Item $dst $bak -Force
Write-Host " backup: $bak"
} else {
Write-Host " backup already present: $bak"
}
Copy-Item $repoSrc $dst -Force
$srcHash = (Get-FileHash $repoSrc -Algorithm SHA256).Hash
$dstHash = (Get-FileHash $dst -Algorithm SHA256).Hash
if ($srcHash -ne $dstHash) { throw "hash mismatch after copy: src=$srcHash dst=$dstHash" }
Write-Host " deployed: $dst"
Write-Host " sha256: $($dstHash.Substring(0,12))"
Write-Host " mtime: $((Get-Item $dst).LastWriteTime)"