Skip to content

Commit

Permalink
Merge branch 'feature/use-printf' into develop
Browse files Browse the repository at this point in the history
* feature/use-printf:
  use `printf` cmd to fix `sed: Argument list too long`
  • Loading branch information
abendy committed Jul 8, 2020
2 parents 5de8dd8 + 16b18e1 commit 8e51809
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions borg-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,20 @@ function main () {
}

function alert () {
FILENAME=$(basename "${BORG_LOG_FILE%}")
ATTACHMENT=`/usr/bin/base64 -i $BORG_LOG_FILE`
BODY=`echo "$1" | /usr/bin/base64`
FILENAME=$(basename "${BORG_LOG_FILE%}")
ATTACHMENT=`/usr/bin/base64 -i -0 $BORG_LOG_FILE`

TEMPLATE="ses-email-template.json"
TMPFILE="/tmp/ses-${RN}"

cp $TEMPLATE $TMPFILE

sed -i -e "s/{SUBJECT}/$1/g" $TMPFILE
sed -i -e "s/{FROM}/$BORG_FROM_EMAIL/g" $TMPFILE
sed -i -e "s/{RECVS}/$BORG_TO_EMAIL/g" $TMPFILE
sed -i -e "s/{BODY}/$BODY/g" $TMPFILE
sed -i -e "s/{FILENAME}/$FILENAME/g" $TMPFILE
sed -i -e "s/{ATTACHMENT}/$ATTACHMENT/g" $TMPFILE
printf '%s\0' $TMPFILE | xargs -0 sed -i -e "s/{ATTACHMENT}/$ATTACHMENT/g" $TMPFILE

aws ses send-raw-email --raw-message file://$TMPFILE > /dev/null
}
Expand Down

0 comments on commit 8e51809

Please sign in to comment.