Skip to content

Instantly share code, notes, and snippets.

@luckman212
Last active March 24, 2024 14:42
Show Gist options
  • Save luckman212/9d751a2b888095573a25ce8296408044 to your computer and use it in GitHub Desktop.
Save luckman212/9d751a2b888095573a25ce8296408044 to your computer and use it in GitHub Desktop.
Script to ping healthchecks.io if Synology HyperBackup was successful
#!/usr/bin/env bash
ENDPOINT='https://hc-ping.com/{insert-HealthChecks-UUID-here}'
LOGFILE='/var/log/synolog/synobackup.log'
[[ -e $LOGFILE ]] || exit 1
awk -f- $LOGFILE <<'EOF'
BEGIN {
FS="\t";
TODAY=strftime("%Y/%m/%d");
RETVAL=1;
}
$2 ~ TODAY && $4 ~ /Backup task finished successfully/ {
RETVAL=0;
exit;
}
END {
exit RETVAL;
}
EOF
case $? in
0) curl -s $ENDPOINT;;
*) : ;; #failed
esac
@luckman212
Copy link
Author

luckman212 commented Dec 29, 2022

Usage

  1. Save this script to your Synology at e.g. /volume1/scripts/syno_hb_hcio.sh
  2. Edit the ENDPOINT= line and paste in your UUID URL.
  3. Use Task Scheduler to execute the script at e.g. 11:55pm (or whatever time that you feel your backup will be completed by)

The script will only work if your backup task has completed before this script executes but still on the same calendar date. If that isn't possible, then you will either need to adjust the awk script to look for the previous day. How to do that is left as an exercise to the reader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment