Skip to content
This repository was archived by the owner on Apr 27, 2024. It is now read-only.

Commit c76ecc2

Browse files
Merge pull request #2 from benjamin-maynard/dev
Version 1.1.1 - Fix Slack alerting
2 parents 66e0096 + d4a5e90 commit c76ecc2

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [v1.1.1] - 16-12-2018
8+
### Fix issue with Slack Alerts
9+
- Fixed issue with failed Slack alerts when log messages contained special characters
10+
- Fixed /bin/ash error when evaluating if the log files are empty or not
11+
- Fixed an error message about the log file not existing when the backup runs successfully
12+
- Suppressed CURL output for Slack alerts
13+
714
## [v1.1.0] - 15-12-2018
815
### Slack Integration & Error Handling
916
- Added Slack Integration

resources/perform-backup.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ else
2626
fi
2727

2828

29-
# Put the contents of the database backup logs into a variable
30-
logcontents=`cat /tmp/aws-database-backup.log`
31-
32-
3329
# Check if any of the backups have failed. If so, exit with a status of 1. Otherwise exit cleanly with a status of 0.
3430
if [ "$has_failed" = true ]
3531
then
3632

3733
# If Slack alerts are enabled, send a notification alongside a log of what failed
3834
if [ "$SLACK_ENABLED" = true ]
3935
then
36+
# Put the contents of the database backup logs into a variable
37+
logcontents=`cat /tmp/aws-database-backup.log`
38+
39+
# Send Slack alert
4040
/slack-alert.sh "One or more backups on database host $TARGET_DATABASE_HOST failed. The error details are included below:" "$logcontents"
4141
fi
4242

resources/slack-alert.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33

44
# Check if there is any value in $2. If so, post an entry to the Slack channel with log information. If not, send a general message that all databases successfully completed
5-
if [ -v "$2"]
5+
if [ "$(printf '%s' "$2")" == '' ]
66
then
77
PAYLOAD="payload={\"channel\": \"$SLACK_CHANNEL\", \"username\": \"$SLACK_USERNAME\", \"text\": \"$1\", \"icon_emoji\": \":slack:\"}"
88
else
9-
PAYLOAD="payload={\"channel\": \"$SLACK_CHANNEL\", \"username\": \"$SLACK_USERNAME\", \"text\": \"$1\`\`\`$2\`\`\`\", \"icon_emoji\": \":slack:\"}"
9+
PAYLOAD="payload={\"channel\": \"$SLACK_CHANNEL\", \"username\": \"$SLACK_USERNAME\", \"text\": \"$1\`\`\`$(echo $2 | sed "s/\"/'/g")\`\`\`\", \"icon_emoji\": \":slack:\"}"
1010
fi
1111

12-
13-
curl -X POST --data-urlencode "$PAYLOAD" "$SLACK_WEBHOOK_URL"
12+
# Send Slack message
13+
curl -s -X POST --data-urlencode "$PAYLOAD" "$SLACK_WEBHOOK_URL" > /dev/null

0 commit comments

Comments
 (0)