我使用autopostgresqlbackup在Debian 8.3上备份我的PostgreSQL数据库。一切正常,但压缩备份不会通过电子邮件发送给我。当我使用“sudo autopostgresqlbackup”运行脚本时,我得到:
Can't stat <redacted name>@gmail.com: No such file or directory
<redacted name>@gmail.com: unable to attach file.
从我的研究中,这可能是由于mutt要求“-a选项必须放在命令行选项的末尾”
脚本本身的相关部分似乎是:
ATTSIZE=`du -c $BACKUPFILES | grep "[[:digit:][:space:]]total$" |sed s/\s*total//`
if [ $MAXATTSIZE -ge $ATTSIZE ]
then
if which biabam >/dev/null 2>&1
then
BACKUPFILES=$(echo $BACKUPFILES | sed -r -e 's#\s+#,#g')
biabam -s "PostgreSQL Backup Log and SQL Files for $HOST - $DATE" $BACKUPFILES $MAILADDR < $LOGFILE
elif which heirloom-mailx >/dev/null 2>&1
then
BACKUPFILES=$(echo $BACKUPFILES | sed -e 's# # -a #g')
heirloom-mailx -s "PostgreSQL Backup Log and SQL Files for $HOST - $DATE" $BACKUPFILES $MAILADDR < $LOGFILE
elif which mutt >/dev/null 2>&1
then
BACKUPFILES=$(echo $BACKUPFILES | sed -e 's# # -a #g')
mutt -s "PostgreSQL Backup Log and SQL Files for $HOST - $DATE" $BACKUPFILES $MAILADDR < $LOGFILE
else
cat "$LOGFILE" | mail -s "WARNING! - Enable to send PostgreSQL Backup dumps, no suitable mail client found on $HOST - $DATE" $MAILADDR
fi
else
cat "$LOGFILE" | mail -s "WARNING! - PostgreSQL Backup exceeds set maximum attachment size on $HOST - $DATE" $MAILADDR
我试图在上面的代码中颠倒“-a #g”的顺序,但后来我遇到了错误。如果有脚本备份Postgres并且只发送一个日志,那么一切正常,但如果我通过电子邮件发送备份文件则不行。任何想法为什么电子邮件附件不起作用?
答案 0 :(得分:0)
已解决:更改了&#34; $ BACKUPFILES $ MAILADDR&lt;的顺序$ LOGFILE&#34;到&#34; $ MAILADDR $ BACKUPFILES&lt; $ LOGFILE&#34;对于mutt,这阻止了试图将电子邮件地址作为附件附加,从而失败。
像这样:
mutt -s "PostgreSQL Backup Log and SQL Files for $HOST - $DATE" $MAILADDR $BACKUPFILES < $LOGFILE