# Smoke-test notify channels with NEW unified format. # Sends one TEST-tagged ntfy push + one TEST-tagged email — no backup run. # Used by unify-backup-notifications task to verify format/delivery without 80-min wait. $ErrorActionPreference = 'Stop' $base = 'C:\ProgramData\backup' $cfg = @{} Get-Content "$base\config.env" | Where-Object { $_ -match '^[A-Z_]+=' } | ForEach-Object { $kv = $_ -split '=', 2 $cfg[$kv[0]] = $kv[1] } $today = Get-Date -Format 'yyyy-MM-dd' $HostLabel = 'RUVDS' $SourceDisplay = "RUVDS ($env:COMPUTERNAME / 80.64.31.36)" $DestDisplay = "kreknin:/volume1/NetBackup/ruvds-iis/$today/" $durationHuman = '1m02s' $sizeStr = '8.66 GB' $snapshotCount = 1 $exported = 25 $logFile = "C:\ProgramData\backup\logs\$today.log" # ntfy $pair = "$($cfg.NTFY_USER):$($cfg.NTFY_PASS)" $auth = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($pair)) $ntfyBody = "$durationHuman, size=$sizeStr, snapshots=$snapshotCount, dest=$DestDisplay, certs=$exported" try { Invoke-RestMethod -Uri "$($cfg.NTFY_URL)/vds-backup" -Method POST ` -Headers @{ Authorization=$auth; Title="[TEST] $HostLabel backup OK $today"; Priority='default'; Tags='green_circle' } ` -Body $ntfyBody -ContentType 'text/plain' -ErrorAction Stop | Out-Null Write-Host 'ntfy_ok' } catch { Write-Host ('ntfy_fail: ' + $_.Exception.Message) } # email $emailBody = @" $HostLabel daily backup completed successfully. Date: $today Duration: $durationHuman Size: $sizeStr Snapshots: $snapshotCount Source: $SourceDisplay Dest: $DestDisplay Components: - sites/snolla - iis-config (applicationHost.config) - iis-backup-webconfiguration - certs ($exported PFX exports) - ssh-config Log: $logFile [TEST RUN — sent from unify-backup-notifications smoke] "@ $secpass = ConvertTo-SecureString $cfg.SMTP_PASS -AsPlainText -Force $mailCred = New-Object PSCredential($cfg.SMTP_USER, $secpass) try { Send-MailMessage -SmtpServer $cfg.SMTP_HOST -Port ([int]$cfg.SMTP_PORT) -UseSsl ` -Credential $mailCred -From $cfg.SMTP_FROM -To $cfg.OPS_NOTIFY_EMAIL ` -Subject "[TEST][$HostLabel] backup OK $today" -Body $emailBody -Encoding UTF8 ` -WarningAction SilentlyContinue -ErrorAction Stop Write-Host 'email_ok' } catch { Write-Host ('email_fail: ' + $_.Exception.Message) }