How do I create a backup in PostgreSQL with .batch

0

I have a bat that creates the backup of a BD in PostgreSQL. This is the batch code:

@echo off 
SET PG_BIN="C:\Program Files\PostgreSQL\bin\pg_dump.exe"
SET PG_HOST=localhost
SET PG_PORT=5432
SET PG_DATABASE=CELAUSystem
SET PG_USER=postgres
SET PG_PASSWORD=7777
SET PG_PATH=C:\Program Files\CELAUSystem
SET PG_FECHA=%date:~11,4%%date:~8,2%%date:~5,2%
SET PG_FILENAME="%PG_PATH%\%PG_DATABASE%_%PG_FECHA%.dump"
%PG_BIN% -U %PG_USER% -v -F c %PG_DATABASE% > %PG_FILENAME%

the result is this:

  

"C: \ Program Files \ PostgreSQL \ 10 \ bin \ pg_dump.exe" -U postgres -v -F c CELAUSystem > C: \ Program Files \ CELAUSystem \ CELAUSystem_20180710.dump

It works fine but when the bat is executed it asks me to type the password of the BD user and does not create the backup until I type it, how can I do it to be automatically typed? Thanks in advance.

    
asked by Pacheco D. Elver 11.07.2018 в 04:34
source

1 answer

1

Nobody answered me, but I found the solution, I will explain it in case it helps someone in the future. In the Batch, when searching for the pg_dump file, the password is written in this way:

  

C: \ Program Files \ PostgreSQL \ 10 \ bin \ PGPASSWORD="7777" pg_dump.exe   That will no longer ask for the password.

    
answered by 11.07.2018 в 18:49