How to pass in password to pg_dump?

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-05-23T23:32:11Z Indexed on 2010/05/23 23:40 UTC
Read the original article Hit count: 115

Filed under:
|
|

I'm trying to create a cronjob to back up my database every night before something catastrophic happens. It looks like this command should meet my needs:

pg_dump dbname | gzip > $(date +%Y-%m-%d).psql.gz

Except after running that, it expects me to type in a password. I can't do that if I run it from cron. How can I pass one in automatically?

© Stack Overflow or respective owner

Related posts about bash

Related posts about postgresql