You can just redirect everything to /dev/null, something like:
#!/bin/bash
# Defaults
LOG_FILE=${NTFY_LOG_FILE:-/dev/null}
NTFY_SERVER=${NTFY_SERVER:-ntfy.sh/raspi5}
# Uncomment to test if you see a message being sent
# curl -s -d "Test!" "$NTFY_SERVER" >>"$LOG_FILE" 2>&1
if [ "$EVENTNAME" == "AFTER" ]; then
if [ "$OPERATIONNAME" == "Backup" ]; then
if [ "$DUPLICATI__PARSED_RESULT" == "Success" ]; then
# Notify success
curl -s -H tags:success -H prio:low \
-d "Backup '$DUPLICATI__backup_name' completed successfully" \
"$NTFY_SERVER" >>"$LOG_FILE" 2>&1
elif [ "$DUPLICATI__PARSED_RESULT" == "Warning" ]; then
# Notify warning
curl -s -H tags:warning -H prio:medium \
-d "Backup '$DUPLICATI__backup_name' completed with warnings" \
"$NTFY_SERVER" >>"$LOG_FILE" 2>&1
else
# Notify failure
curl -s -H tags:error -H prio:high \
-d "Backup '$DUPLICATI__backup_name' failed with status: $DUPLICATI__PARSED_RESULT" \
"$NTFY_SERVER" >>"$LOG_FILE" 2>&1
fi
fi
fi
If it fails for some reason, you can set the LOG_FILE env var, or just edit the script to log somewhere.
My plan is to support templates, so it would be simple to format the message to fit whatever destination.