# PostgreSQL backup for TheBet365 (dev/docker-compose defaults)
param(
  [string]$OutDir = ".\backups",
  [string]$DbName = "thebet365",
  [string]$DbUser = "thebet365",
  [string]$DbHost = "127.0.0.1",
  [int]$DbPort = 5432
)

$ErrorActionPreference = "Stop"
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null

$stamp = Get-Date -Format "yyyyMMdd-HHmmss"
$outFile = Join-Path $OutDir "thebet365-$stamp.sql"

Write-Host "Backing up $DbName to $outFile ..."
$env:PGPASSWORD = $env:THEBET365_DB_PASSWORD
if (-not $env:PGPASSWORD) {
  Write-Warning "Set THEBET365_DB_PASSWORD if your Postgres requires a password."
}

pg_dump -h $DbHost -p $DbPort -U $DbUser -d $DbName -F p -f $outFile
Write-Host "Done: $outFile"
