Created
March 26, 2018 17:12
-
-
Save levi-turner/f2d626d1ec8af591c6926666d7777795 to your computer and use it in GitHub Desktop.
Backing up the QSR database using PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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