zertrin / duplicity-backup.sh

Bash wrapper script for automated backups with duplicity supporting Amazon's S3 online storage as well as other storage destinations (ftp, rsync, sftp, local storage...).
https://zertrin.org/projects/duplicity-backup/
GNU General Public License v3.0
766 stars 187 forks source link

Mail command fails on Centos 5.5 i686 (patch) #21

Closed philcryer closed 12 years ago

philcryer commented 12 years ago

On Centos 5.5 i686, even with the mailx package installed from yum, the script still won't send via mailx (which isn't in the PATH, or even an installed file (?)) I'm not a big Centos user, so I fixed the script so that it will also send with the stock mail command, this requires two patches:

diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
index 89861be..5037292 100644
--- a/duplicity-backup.conf.example
+++ b/duplicity-backup.conf.example
@@ -160,6 +160,7 @@ EMAIL_SUBJECT=

 # command to use to send mail
 MAIL="mailx"
+#MAIL="mail"
 #MAIL="ssmtp"

 # TROUBLESHOOTING: If you are having any problems running this script it is

diff --git a/duplicity-backup.sh b/duplicity-backup.sh
index c3fc583..68c5f35 100755
--- a/duplicity-backup.sh
+++ b/duplicity-backup.sh
@@ -241,6 +241,8 @@ email_logfile()
           elif [ "$MAIL" = "mailx" ]; then
             EMAIL_FROM=${EMAIL_FROM:+"-r ${EMAIL_FROM}"}
             cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" $EMAIL_FROM ${EMAIL_TO}
+          elif [ "$MAIL" = "mail" ]; then
+            cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" $EMAIL_FROM ${EMAIL_TO} -- -f ${EMAIL_FROM}
           fi
           echo -e "Email alert sent to ${EMAIL_TO} using ${MAIL}" >> ${LOGFILE}
       fi
philcryer commented 12 years ago

submitted a pull request instead.