PIVOTAL HAWQ 备份 - shell 脚本错误

PIVOTAL HAWQ Backup - shell script error

当我尝试使用 shell 脚本备份 PIVOTAL HAWQ 数据库时。

获取错误:

/home/gpadmin/backup_db.sh: line 12: pg_dump: command not found

输入shell脚本:backup_db.sh

#!/bin/bash
# Location to place backup.
backup_dir="/home/backup/"
#String to append at the name of the backup files
backup_date=`date +%d-%m-%Y`
#Numbers of days we want to keep copy databases
number_of_days=7
databases=(prod test gpadmin)
for i in ${databases[@]}; do
  if [ "$i" != "template0" ] && [ "$i" != "template1" ]; then
    echo Dumping $i to $backup_dir$i\_$backup_date
    pg_dump $i|gzip > $backup_dir$i\_$backup_date.gz
  fi
done
find $backup_dir -type f -prune -mtime +$number_of_days -exec rm -f {} \;

CRONTAB: SHELL 脚本条目 - */5 * * * * /home/gpadmin/backup_db.sh > /tmp/bkp.log

当运行时shell手动转储数据。但同时不能通过每 5 分钟运行一次的 crontab 工作。

如有任何帮助,我们将不胜感激。

crontab 找不到 pg_dump binaries.Please 尝试 运行 绝对路径为 pg_dump 的脚本(usr/local/hawq/bin/pg_dump).

您也可以在调用 pg_dump 调用之前获取 /usr/local/hawq/greenplum_path.sh。

如果您从 cron 运行 获取 hawq 二进制文件,则需要在脚本中获取 hawq 二进制文件。

#!/bin/bash
# Source hawq binaries
. /usr/local/hawq/greenplum_path.sh  #Change into your exact binaries location

# Location to place backup.
backup_dir="/home/backup/"