By jongarrido | October 7, 2015 | 0 Comment
How to perform a dayly backup of a postgresql database on a windows server.
This post it’s an update of this one. On this case this steps are refered to a 9.4 version of postgresql on a Windows Server 2012.
In a new folder, for example d:/pg_backup, you need to have the pg_dump.exe command available to run de . For this purpose you need to create a bin folder with the next libraries (and also pg_dump) inside :
These files are available at your postgresql instalation folder C:\path\to\posgresql-9.4\bin
Then you need to create a batch file in your d:/pg_backup folder like this. You can name it as mydbbackup.bat.
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
echo datestr is %datestr%
echo backup file name is %BACKUP_FILE%
d:\pg_backup\bin\pg_dump -i -h <host>-p 5432 -U <user>-F c -b -v -f %BACKUP_FILE% <dbname>
Here you must replece with your custom data:
Then you can add a new task in your windows sheduled tasks to run this script dayly.