2016-04-14 83 views
1

我正在使用autopostgresqlbackup在Debian 8.3上備份我的PostgreSQL數據庫。一切正常,除了壓縮備份沒有通過電子郵件發送給我。當我用「命令autopostgresqlbackup」運行該腳本,我得到:Postgres備份腳本不通過電子郵件發送

Can't stat <redacted name>@gmail.com: No such file or directory 
<redacted name>@gmail.com: unable to attach file. 

從我的研究,這可能通過要求「-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

解決:改變的「$ BACKUPFILES $ MAILADDR < $ LOGFILE」到「$ MAILADDR $ BACKUPFILES < $ LOGFILE」命令的狗,而這種停止狗從試圖連接的電子郵件地址作爲附件,並從而失敗。

像這樣:

mutt -s "PostgreSQL Backup Log and SQL Files for $HOST - $DATE" $MAILADDR $BACKUPFILES < $LOGFILE