SHOWCASE: A script to get Slack notifications before and after Virtualmin backups

I used this script to notify me before and after backups:


# Examples

# Command to run before backup
# sh /root/ Begin Superman $BACKUP_DEST

# Command to run after backup
# sh /root/ End Superman $BACKUP_DEST $BACKUP_STATUS

# Command line parameters

message="$1 $2 backup to $3 $4"
echo $message

# Read the Slack Hook URL from the .env file
source /root/.env

# Post to Slack
curl -X POST -H 'Content-type: application/json' --data "{'text':'$message'}" $SLACK_HOOK

If you’re interested in using it, please check out the instructions on Github:

If you’re an open source Shell script developer, please see if you can help us improve the script. The following are current outstanding tasks:

  • Instead of outputting 1 or 0 for backup success and fail, use a word such as SUCCESS or FAIL

  • Make Slack do something special when it fails, e.g. present the output in the colour red, or play a sound

  • Keeping track of backup times is super NB. It would be great that when the verb is read as “begin” (case insensitive) that a timer is created, which is read again afterwards if “end” is encountered


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.