Sign up ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I've got a working postgreSQL database with following pg_hba.conf:

local   all             postgres                                peer
local   all             all                                     md5
host    all             all               md5
host    all             all             ::1/128                 md5
hostssl all             dbadmin       md5

Which, to my understanding is correct, and only allows local connections and from my home-ip via SSL. Both via a md5 password.

I now want a local bash script to run some things on the databases (backups). For this I created a new user backup_user; as the script needs to run autonomous my thoughts were to create a line for this user to trust from the the lo:

host   all           backup_user    trust

But when I login via SSH and run this command I have to type the password....

psql -U backup_user -p 5454

What is the best way to let the script do its thing? If it matters, I want this script to sun: Automated Backup

share|improve this question
Why not set the auth method to md5 for the backup user, and use a .pgpass file? – bma Nov 28 '13 at 19:48
Hmm because I didn't kow of the existence off .pgpass.... Where on my (ubunutu) server should I find this file? – stUrb Nov 28 '13 at 20:33
For connecting through Unix domain socket (and that's how you connect as you don't specify a host via -h) replace that line with local all backup_user peer and move it at just after the first line. – Milen A. Radev Nov 28 '13 at 20:35
O.K. I don't want to use .pgpass as the password is stored in there as plain text. – stUrb Nov 28 '13 at 21:03
Then move your original line just before this one: host all all md5. – Milen A. Radev Nov 28 '13 at 21:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.