Skip to content

Commit cfce2cc

Browse files
committed
update notifications
1 parent 011bfb0 commit cfce2cc

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

resources/notify.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
11
#/bin/sh
22

3-
4-
# 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 [ "$(printf '%s' "$2")" == '' ]
6-
then
7-
PAYLOAD="payload={\"channel\": \"$NOTIFY_CHANNEL\", \"username\": \"$NOTIFY_USERNAME\", \"text\": \"$1\", \"icon_emoji\": \":slack:\"}"
8-
else
9-
PAYLOAD="payload={\"channel\": \"$NOTIFY_CHANNEL\", \"username\": \"$NOTIFY_USERNAME\", \"text\": \"$1\`\`\`$(echo $2 | sed "s/\"/'/g")\`\`\`\", \"icon_emoji\": \":slack:\"}"
10-
fi
11-
12-
# Send Slack message
13-
curl -s -X POST --data-urlencode "$PAYLOAD" "$NOTIFY_WEBHOOK_URL" > /dev/null
3+
curl -X POST -d $PAYLOAD $NOTIFICATION_WEBHOOK_URL

resources/perform-backup.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# Set the has_failed variable to false. This will change if any of the subsequent database backups/uploads fail.
55
has_failed=false
6+
backup_name=""
67

78

89
# Loop through all the defined databases, seperating by a ,
@@ -14,9 +15,9 @@ do
1415
then
1516

1617
echo -e "Database backup successfully completed for $CURRENT_DATABASE at $(date +'%d-%m-%Y %H:%M:%S')."
17-
18+
backup_name=$CURRENT_DATABASE_$(date +"%Y-%m-%d_%H-%M-%S").sql
1819
# Perform the upload to S3. Put the output to a variable. If successful, print an entry to the console and the log. If unsuccessful, set has_failed to true and print an entry to the console and the log
19-
if awsoutput=$(aws s3 cp /tmp/$CURRENT_DATABASE.sql $AWS_BUCKET_URI$AWS_BUCKET_BACKUP_PATH/$CURRENT_DATABASE.sql 2>&1)
20+
if awsoutput=$(aws s3 cp /tmp/$CURRENT_DATABASE.sql $AWS_BUCKET_URI$AWS_BUCKET_BACKUP_PATH/$backup_name 2>&1)
2021
then
2122
echo -e "Database backup successfully uploaded for $CURRENT_DATABASE at $(date +'%d-%m-%Y %H:%M:%S')."
2223
else
@@ -55,7 +56,7 @@ else
5556
# If Slack alerts are enabled, send a notification that all database backups were successful
5657
if [ "$NOTIFY_ENABLED" = true ]
5758
then
58-
/notify.sh "All database backups successfully completed on database host $TARGET_DATABASE_HOST."
59+
/notify.sh "Backup created: $backup_name"
5960
fi
6061

6162
exit 0

0 commit comments

Comments
 (0)