From 31da9c897ca109d72b82e008d2c5306c39d0e4fb Mon Sep 17 00:00:00 2001 From: Joeri Verdeyen Date: Wed, 3 Jul 2013 09:21:20 +0200 Subject: [PATCH] Sendmail as mail command --- duplicity-backup.conf.example | 17 +++++++++-------- duplicity-backup.sh | 8 +++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example index a8da54c..bde6dc9 100644 --- a/duplicity-backup.conf.example +++ b/duplicity-backup.conf.example @@ -44,7 +44,7 @@ AWS_ACCESS_KEY_ID="foobar_aws_key_id" AWS_SECRET_ACCESS_KEY="foobar_aws_access_key" # S3CMD INFORMATION -# Most people don't need this, but in some cases +# Most people don't need this, but in some cases # you may want to specify a custom configuration file # to pass to s3cmd. If so, set the S3CMD_CONF_FILE variable # to the full path of this custom config file. @@ -65,15 +65,15 @@ ENCRYPTION='yes' PASSPHRASE="foobar_gpg_passphrase" # Specify which GPG keys you would like to use (even if you have only one). -# If you are running this from a cron, it is highly recommended to create separate -# signature and encryption keys, because you have to specify the password for the -# GPG_SIGN_KEY via the above PASSPHRASE variable +# If you are running this from a cron, it is highly recommended to create separate +# signature and encryption keys, because you have to specify the password for the +# GPG_SIGN_KEY via the above PASSPHRASE variable # (see http://www.debian-administration.org/articles/209#d0e109). -# If you are not running the script from a cron, duplicity should prompt you for the +# If you are not running the script from a cron, duplicity should prompt you for the # GPG_SIGN_KEY password. # If you choose to use the same GPG key for encryption and signature, set it both # in GPG_ENC_KEY and GPG_SIGN_KEY. -# Comment out if you're using only PASSPHRASE (symmetric encryption) or not using +# Comment out if you're using only PASSPHRASE (symmetric encryption) or not using # encryption at all. GPG_ENC_KEY="foobar_gpg_key" GPG_SIGN_KEY="foobar_gpg_key" @@ -116,7 +116,7 @@ DEST="s3+http://backup-bucket/backup-folder/" # ) # # Simpler example with one location: -INCLIST=( "/home/foobar_user_name/Documents/Prose/" ) +INCLIST=( "/home/foobar_user_name/Documents/Prose/" ) # EXCLUDE LIST OF DIRECTORIES # Even though I am being specific about what I want to include, @@ -128,7 +128,7 @@ EXCLIST=( "/home/*/Trash" \ # STATIC BACKUP OPTIONS # Here you can define the static backup options that you want to run with -# duplicity. Reference is the manpage of duplicity (available at +# duplicity. Reference is the manpage of duplicity (available at # http://duplicity.nongnu.org/duplicity.1.html for example) # Useful examples are `--full-if-older-than` option and (for those using # Amazon S3 in Europe) `--s3-use-new-style` and `--s3-european-buckets` options @@ -176,6 +176,7 @@ EMAIL_SUBJECT= MAIL="mailx" #MAIL="mail" #MAIL="ssmtp" +#MAIL="sendmail" # TROUBLESHOOTING: If you are having any problems running this script it is # helpful to see the command output that is being generated to determine if the diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 3fe3bbf..afb16be 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -30,7 +30,7 @@ # Default config file (don't forget to copy duplicity-backup.conf.example to # match that path) # NOTE: It can be useful not to edit this script at all to ease future updates -# so the config file can be specified directly on the command line too +# so the config file can be specified directly on the command line too # with the -c option. CONFIG="duplicity-backup.conf" @@ -270,6 +270,8 @@ email_logfile() else cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" $EMAIL_FROM ${EMAIL_TO} -- -f ${EMAIL_FROM} fi + elif [[ "$MAIL" ~= "sendmail" ]]; then + (echo """Subject: ${EMAIL_SUBJECT}""" ; cat ${LOGFILE}) | ${MAILCMD} -f ${EMAIL_FROM} ${EMAIL_TO} elif [ "$MAIL" = "nail" ]; then cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" $EMAIL_FROM ${EMAIL_TO} fi @@ -302,9 +304,9 @@ get_source_file_size() # Remove space as a field separator temporarily OLDIFS=$IFS IFS=$(echo -en "\t\n") - + DUEXCFLAG="--exclude-from=" - if [[ `uname` == 'FreeBSD' || `uname` == 'Darwin' ]]; then + if [[ `uname` == 'FreeBSD' || `uname` == 'Darwin' ]]; then DUEXCFLAG="-I " fi