JON GARRIDO GIS EXPERT - DESARROLLADOR GIS

DESARROLLADOR GIS FREELANCE

Automated Postgresql 9.4 Backup on Windows

By jongarrido | octubre 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 :

libeay32.dll

libiconv-2.dll

libintl-8.dll

libpq.dll

pg_dump.exe

ssleay32.dll

zlib1.dll

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.

@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=_%datestr%.backup
echo backup file name is %BACKUP_FILE%
SET PGPASSWORD= echo on
d:\pg_backup\bin\pg_dump -i -h -p 5432 -U -F c -b -v -f %BACKUP_FILE%

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.

 

That’s all

 

 

TAGS

0 Comments

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *