OS: Ubuntu Xenial 16.04 LTS
PostgreSQL Version: 9.5.4
I am trying to set up automatic database backups on my server, and every time I run pg_dump
, it tells me that no password was supplied. Here's the command I'm using to test:
pg_dump --host $DB_HOST --port 5432 --username $DB_USER --no-password --format custom --blobs --verbose --file ~/backups/postgresql/test.backup $DB_NAME
All of my environment variables are working just fine. To supply PostgreSQL with the password, I've created a .pgpass
file in ~/.pgpass
. Here's what it looks like:
# hostname:port:database:username:password $DB_HOST:5432:$DB_NAME:$DB_USER:$DB_PASS
The file has 0600
permissions, as specified in the guide. Yet, for some reason, it's not using the password whenever I run pg_dump
. I've looked at other answers and multiple guides online but still can't figure out what the problem is.
Any help would be greatly appreciated.