11 lines
584 B
PowerShell
11 lines
584 B
PowerShell
|
|
# Dumps the Subfeed Postgres database to backups\subfeed-<timestamp>.dump (custom format).
|
||
|
|
# Run from the project root: .\scripts\backup.ps1
|
||
|
|
$ErrorActionPreference = "Stop"
|
||
|
|
$user = if ($env:POSTGRES_USER) { $env:POSTGRES_USER } else { "subfeed" }
|
||
|
|
$dbname = if ($env:POSTGRES_DB) { $env:POSTGRES_DB } else { "subfeed" }
|
||
|
|
New-Item -ItemType Directory -Force -Path "backups" | Out-Null
|
||
|
|
$ts = Get-Date -Format "yyyyMMdd-HHmmss"
|
||
|
|
$out = "backups\subfeed-$ts.dump"
|
||
|
|
docker compose exec -T db pg_dump -U $user -Fc $dbname | Set-Content -NoNewline -Encoding Byte $out
|
||
|
|
Write-Output "Wrote $out"
|