我试过了
如果我一次又一次输入密码,自动备份的脚本(https://wiki.postgresql.org/wiki/Automated_Backup_on_Linux)就可以工作了,这就是我为所有命令添加-w的原因。由于某种原因,它不会读取.pgpass文件。
有多条错误消息,但通常都是这样。
pg_dumpall: could not connect to database "template1": FATAL: password authentication failed for user "postgres"
致命:用户" postgres"
的密码验证失败pg_pass文件:
localhost:5432:my_db:postgres:password
命令行:
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!
答案 0 :(得分:0)
您应该向pg_dump
和pg_dumpall
提供实际的来电,以获得更详细的答案。
但是,从您的输出中我看到pg_dumpall
(?)尝试连接到数据库template1
,但在.pgpass
文件中,唯一的数据库是my_db
。< / p>
您必须为您尝试连接的所有数据库添加.pgpass
条目。