我想使用中提供的备份脚本(我的脚本与给定链接中的脚本相同,仅更改了配置):
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 中提供的所有内容,但它没有..