82ff39370c70024441295e16f8133315da40150d

Author
zertrin <zrk951@gmail.com>
Committer
zertrin <zrk951@gmail.com>
Date

Message

Merge pull request #47 from jverdeyen/feature/sendmail

added sendmail as mail command

Diff

 1diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
 2index a8da54c6ac722147b558cd18095185ec5cf9fbc4..bde6dc9accfa39ba4ed4f7eeec45db2c0b0ac481 100644
 3--- a/duplicity-backup.conf.example
 4+++ b/duplicity-backup.conf.example
 5@@ -44,7 +44,7 @@ AWS_ACCESS_KEY_ID="foobar_aws_key_id"
 6 AWS_SECRET_ACCESS_KEY="foobar_aws_access_key"
 7 
 8 # S3CMD INFORMATION
 9-# Most people don't need this, but in some cases 
10+# Most people don't need this, but in some cases
11 # you may want to specify a custom configuration file
12 # to pass to s3cmd. If so, set the S3CMD_CONF_FILE variable
13 # to the full path of this custom config file.
14@@ -65,15 +65,15 @@ ENCRYPTION='yes'
15 PASSPHRASE="foobar_gpg_passphrase"
16 
17 # Specify which GPG keys you would like to use (even if you have only one).
18-# If you are running this from a cron, it is highly recommended to create separate 
19-# signature and encryption keys, because you have to specify the password for the 
20-# GPG_SIGN_KEY via the above PASSPHRASE variable 
21+# If you are running this from a cron, it is highly recommended to create separate
22+# signature and encryption keys, because you have to specify the password for the
23+# GPG_SIGN_KEY via the above PASSPHRASE variable
24 # (see http://www.debian-administration.org/articles/209#d0e109).
25-# If you are not running the script from a cron, duplicity should prompt you for the 
26+# If you are not running the script from a cron, duplicity should prompt you for the
27 # GPG_SIGN_KEY password.
28 # If you choose to use the same GPG key for encryption and signature, set it both
29 # in GPG_ENC_KEY and GPG_SIGN_KEY.
30-# Comment out if you're using only PASSPHRASE (symmetric encryption) or not using 
31+# Comment out if you're using only PASSPHRASE (symmetric encryption) or not using
32 # encryption at all.
33 GPG_ENC_KEY="foobar_gpg_key"
34 GPG_SIGN_KEY="foobar_gpg_key"
35@@ -116,7 +116,7 @@ DEST="s3+http://backup-bucket/backup-folder/"
36 #        )
37 #
38 # Simpler example with one location:
39-INCLIST=( "/home/foobar_user_name/Documents/Prose/" ) 
40+INCLIST=( "/home/foobar_user_name/Documents/Prose/" )
41 
42 # EXCLUDE LIST OF DIRECTORIES
43 # Even though I am being specific about what I want to include,
44@@ -128,7 +128,7 @@ EXCLIST=(   "/home/*/Trash" \
45 
46 # STATIC BACKUP OPTIONS
47 # Here you can define the static backup options that you want to run with
48-# duplicity. Reference is the manpage of duplicity (available at 
49+# duplicity. Reference is the manpage of duplicity (available at
50 # http://duplicity.nongnu.org/duplicity.1.html for example)
51 # Useful examples are `--full-if-older-than` option and (for those using
52 # Amazon S3 in Europe) `--s3-use-new-style` and `--s3-european-buckets` options
53@@ -176,6 +176,7 @@ EMAIL_SUBJECT=
54 MAIL="mailx"
55 #MAIL="mail"
56 #MAIL="ssmtp"
57+#MAIL="sendmail"
58 
59 # TROUBLESHOOTING: If you are having any problems running this script it is
60 # helpful to see the command output that is being generated to determine if the
61diff --git a/duplicity-backup.sh b/duplicity-backup.sh
62index 3fe3bbf5ace0e2db7f1837ac43eef21738aeeee9..afb16be8633d46f71d9e6cfe0e7aa0916b222412 100755
63--- a/duplicity-backup.sh
64+++ b/duplicity-backup.sh
65@@ -30,7 +30,7 @@
66 # Default config file (don't forget to copy duplicity-backup.conf.example to
67 # match that path)
68 # NOTE: It can be useful not to edit this script at all to ease future updates
69-#       so the config file can be specified directly on the command line too 
70+#       so the config file can be specified directly on the command line too
71 #       with the -c option.
72 CONFIG="duplicity-backup.conf"
73 
74@@ -270,6 +270,8 @@ email_logfile()
75             else
76                cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" $EMAIL_FROM ${EMAIL_TO} -- -f ${EMAIL_FROM}
77             fi
78+          elif [[ "$MAIL" ~= "sendmail" ]]; then
79+            (echo """Subject: ${EMAIL_SUBJECT}""" ; cat ${LOGFILE}) | ${MAILCMD} -f ${EMAIL_FROM} ${EMAIL_TO}
80           elif [ "$MAIL" = "nail" ]; then
81             cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" $EMAIL_FROM ${EMAIL_TO}
82           fi
83@@ -302,9 +304,9 @@ get_source_file_size()
84   # Remove space as a field separator temporarily
85   OLDIFS=$IFS
86   IFS=$(echo -en "\t\n")
87-  
88+
89   DUEXCFLAG="--exclude-from="
90-  if [[ `uname` == 'FreeBSD' || `uname` == 'Darwin' ]]; then 
91+  if [[ `uname` == 'FreeBSD' || `uname` == 'Darwin' ]]; then
92      DUEXCFLAG="-I "
93   fi
94