Files
WebUp Cloud db82325ed7
Verify control plane / verify (push) Canceled after 0s
Initial import of WebUp Cloud
2026-11-07 13:31:14 +08:00

14 lines
911 B
PowerShell

param([string]$OutputDirectory = './data/backups')
$ErrorActionPreference = 'Stop'
Set-Location -LiteralPath (Split-Path -Parent $PSScriptRoot)
New-Item -ItemType Directory -Force -Path $OutputDirectory | Out-Null
$fileName = 'platform-' + (Get-Date -Format 'yyyyMMdd-HHmmss') + '.dump'
$backupTarget = Join-Path (Resolve-Path -LiteralPath $OutputDirectory).Path $fileName
# Docker cp preserves binary format on Windows PowerShell 5.1.
docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" -Fc -f /tmp/platform-backup.dump platform'
if ($LASTEXITCODE -ne 0) { throw 'pg_dump failed; backup not completed.' }
$containerId = docker compose ps -q postgres
docker cp "${containerId}:/tmp/platform-backup.dump" $backupTarget
if ($LASTEXITCODE -ne 0) { throw 'Backup copy failed.' }
Write-Host "Backup created: $backupTarget. This covers platform PostgreSQL only; storage requires a separate S3 backup."