Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanljj/d518d22298aaab1e197f69584cdb1b96 to your computer and use it in GitHub Desktop.
Save alanljj/d518d22298aaab1e197f69584cdb1b96 to your computer and use it in GitHub Desktop.
Automated_Backup_Postgresql_on_Windows
@echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
set dow=%%i
set month=%%j
set day=%%k
set year=%%l
)
set datestr=%month%_%day%_%year%
echo datestr is %datestr%
set BACKUP_FILE=<NameOfTheFile>_%datestr%.backup
echo backup file name is %BACKUP_FILE%
SET PGPASSWORD=<PassWord>
echo on
bin\pg_dump -i -h <HostName> -p 5432 -U <UserName> -F c -b -v -f %BACKUP_FILE% <DATABASENAME>
rem from https://wiki.postgresql.org/wiki/Automated_Backup_on_Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment