Reputation:
I have tried
The script (https://wiki.postgresql.org/wiki/Automated_Backup_on_Linux) for automated backup works if I type the password again and again which is why i added -w to all the commands. It for some reason does not read the .pgpass file .
There are multiple error messages but they are generally this.
pg_dumpall: could not connect to database "template1": FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
pg_pass file :
localhost:5432:my_db:postgres:password
command line :
username@droplet:~/ProjectDir$ bash cronjob/db_backup/pg_backup.sh
Making backup directory in /home/backups/database/postgresql/2017-12-06/
Performing globals backup
--------------------------------------------
Globals backup
cronjob/db_backup/pg_backup.sh: line 80: /home/backups/database/postgresql/2017-12-06/globals.sql.gz.in_progress: Permission denied
pg_dumpall: could not connect to database "template1": fe_sendauth: no password supplied
[!!ERROR!!] Failed to produce globals backup
Performing schema-only backups
--------------------------------------------
psql: fe_sendauth: no password supplied
The following databases were matched for schema-only backup:
Performing full backups
--------------------------------------------
psql: fe_sendauth: no password supplied
All database backups complete!
Upvotes: 5
Views: 4476
Reputation: 246083
You should supply the actual calls to pg_dump
and pg_dumpall
for a more detailed answer.
However, from your output I see that pg_dumpall
(?) tries to connect to database template1
, but in your .pgpass
file the only database is my_db
.
You'll have to add entries to .pgpass
for all databases to which you are trying to connect.
localhost:5432:mydb1:postgres:password
localhost:5432:mydb2:postgres:password
localhost:5432:mydb3:postgres:password
Alternatively, you are also able to put an *
as a placeholder for different database names.
localhost:5432:*:postgres:password
Make sure that all the fields in .pgpass
are the right/matching ones. If any of them (host, port, etc.) don't match, the unclear, uninformative and arguably wrong fe_sendauth: no password supplied
error message will be the same.
Upvotes: 3