bashpostgresqldatabase-backups

postgresql: .pgpass not working


I have created a .pgpass file in my home directory which looks like this

localhost:5432:somedb:someuser:somepass

I am using a shell script which creates a directory and puts a pg_dump of somedb there :

mkdir directory
pg_dump somedb > directory/somefile.dump

It still prompts for the password.

Where is the mistake here ?


Solution

  • Did you try specifying the host, user, & db?

    pg_dump -U someuser -h localhost somedb > directory/somefile.dump