Skip to content

Push Notification Slack

Example:

Bash
#!/bin/bash

ls -laht /opt/backup/mysql/integration* | grep $(date +%y%m%d) > mysqlbackups.json
sed -i '1i===========================' mysqlbackups.json
sed -i '2i== MYSQL - NOTIFICATION -==' mysqlbackups.json
sed -i '3i===========================' mysqlbackups.json

mysqlbackups=$(cat mysqlbackups.json)

curl -H "Content-type: application/json" \
--data '{"channel":"backup-notifications","blocks":[{"type":"section","text":{"type":"mrkdwn","text":"'"\`\`\`$mysqlbackups\`\`\`"'"}}]}' \
-H "Authorization: Bearer xoxb-1964176XXXXX-XXXXX34257493-KHSApj5IIBvSPGbWFEjku1q7" \
-X POST https://slack.com/api/chat.postMessage
Back to top