Skip to content

Instantly share code, notes, and snippets.

@levi-turner
Created March 26, 2018 17:12
Show Gist options
  • Save levi-turner/f2d626d1ec8af591c6926666d7777795 to your computer and use it in GitHub Desktop.
Save levi-turner/f2d626d1ec8af591c6926666d7777795 to your computer and use it in GitHub Desktop.
Backing up the QSR database using PowerShell
# Set the postgres user password
$env:PGPASSWORD = 'password';
# Get the date and format into YYYY-MM-DD format
$date = Get-Date -format "yyyy-MM-dd"
# Test if there is a QSR directory
Set-Location /
if (Test-Path C:\QSR) {
Write-Host "C:\QSR already exists." -ForegroundColor Green
} else {
Write-Host "Creating QSR directory for PostgreSQL backup" -ForegroundColor Green
mkdir QSR
}
# Goto PostgreSQL binary directory
Set-Location "C:\Program Files\Qlik\Sense\Repository\PostgreSQL\9.6\bin\"
# Dump the DB
Start-Process .\pg_dump.exe "--host localhost --port 4432 --username postgres -b -F t -f c:\QSR\QSR_$($date).tar QSR" -Wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment