Elitmiar
Elitmiar

Reputation: 36879

When backing up a postgres database I get prompted for a password

I'm busy backing up my postgres db, I run the following command

pg_dump -d data -U postgres -h 127.0.0.1 -CdiOv > data.sql

I however have one problem I get asked for the password, if I want to add this into a cron I do not want to get promted for the password. Is there any way to do this without the password prompt?

Upvotes: 0

Views: 421

Answers (2)

user80168
user80168

Reputation:

First of all: never use -d option to pg_dump. Do you even know what it does?

Second: use pgpass file or PGPASSWORD env variable.

Upvotes: 1

wadesworld
wadesworld

Reputation: 13763

Use ~/.pgpass. pgpass documentation

Lots more details to be found on Google, searching for "pg_dump password".

Upvotes: 1

Related Questions