我想使用提供的备份脚本(我的脚本与给定链接中的相同,只更改了配置):
http://wiki.postgresql.org/wiki/Automated_Backup_on_Linux
在pg_backup.config中 我补充说:
BACKUP_USER = myusername (that has postgresql superuser access)
HOST = localhost
USERNAME = myusername (that has postgresql superuser access)
更新完整的pg_backup.config:
##############################
## POSTGRESQL BACKUP CONFIG ##
##############################
# Optional system user to run backups as. If the user the script is running as doesn't match this
# the script terminates. Leave blank to skip check.
BACKUP_USER=myusername
# Optional hostname to adhere to pg_hba policies. Will default to "localhost" if none specified.
HOSTNAME=localhost
# Optional username to connect to database as. Will default to "postgres" if none specified.
USERNAME=myusername
# This dir will be created if it doesn't exist. This must be writable by the user the script is
# running as.
BACKUP_DIR=/home/myusername/openerp/7.0/backup
# List of strings to match against in database name, separated by space or comma, for which we only
# wish to keep a backup of the schema, not the data. Any database names which contain any of these
# values will be considered candidates. (e.g. "system_log" will match "dev_system_log_2010-01")
SCHEMA_ONLY_LIST=""
# Will produce a custom-format backup if set to "yes"
ENABLE_CUSTOM_BACKUPS=no
# Will produce a gzipped plain-format backup if set to "yes"
ENABLE_PLAIN_BACKUPS=yes
#### SETTINGS FOR ROTATED BACKUPS ####
# Which day to take the weekly backup from (1-7 = Monday-Sunday)
DAY_OF_WEEK_TO_KEEP=5
# Number of days to keep daily backups
DAYS_TO_KEEP=7
# How many weeks to keep weekly backups
WEEKS_TO_KEEP=5
但是当我尝试使用命令运行pg_backup.sh时:
bash pg_backup.sh
我收到此错误消息:
Performing full backups
--------------------------------------------
psql: FATAL: no pg_hba.conf entry for host "shows my external IP", user "postgres", database "postgres", SSL on
FATAL: no pg_hba.conf entry for host "shows my external ip", user "postgres", database "postgres", SSL off
All database backups complete!
此外,它打印出所有数据库都已完成,但它不会进行任何备份。
当我手动尝试此命令时:
pg_dump -Fp -h "localhost" -U "myusername" "mydatabase" | gzip > /home/myusername/openerp/7.0/backup/"mydatabase".sql.gz;
然后它完全备份!
所以问题是为什么它会给出如此奇怪的错误? 首先它使用我的外部ip,当它应该使用localhost,第二个它连接postgres用户(或至少它显示那样),当它应该连接myusername,第三,脚本错过一些错误检查,因为它打印所有数据库已成功备份,实际上根本没有任何备份。
同样查看脚本看起来应该像pg_backup.config中提供的那样正确使用所有内容,但它不会..