Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error notification even though there is no error #381

Open
qlereboursBS opened this issue Oct 20, 2024 · 0 comments
Open

Getting error notification even though there is no error #381

qlereboursBS opened this issue Oct 20, 2024 · 0 comments
Labels

Comments

@qlereboursBS
Copy link

Summary

The backup runs every night, and I have an empty notification every night (the arguments are empty), even though there is no error when checking the logs.

Steps to reproduce

Set the environment variable: NOTIFICATION_CUSTOM_SCRIPT=/assets/custom-scripts/backup-error-notifier.sh
and create this backup-error-notifier.sh file:

#!/bin/bash

# Arguments
timestamp=$1
logfile=$2
errorcode=$3
subject=$4
message=$5

# Convert UNIX timestamp to a readable date format
date=$(date -d @$timestamp +"%Y-%m-%d %H:%M:%S") # Linux
#date=$(date -r $timestamp +"%Y-%m-%d %H:%M:%S") # macOS

# Webhook URL
webhook_url="https://discord.com/api/webhooks/..."

# JSON payload for discord
payload=$(cat <<EOF
{
  "username": "Error Notifier",
  "embeds": [
    {
      "title": "$subject",
      "description": "$message",
      "color": 16711680,
      "fields": [
        {
          "name": "Timestamp",
          "value": "$date"
        },
        {
          "name": "Logfile",
          "value": "$logfile"
        },
        {
          "name": "Error Code",
          "value": "$errorcode"
        }
      ]
    }
  ]
}
EOF
)

# Send curl
curl -H "Content-Type: application/json" -d "$payload" "$webhook_url"

What is the expected correct behavior?

As stated in the documentation: This image has capabilities on sending notifications via a handful of services when a backup job fails. This is a global option that cannot be individually set per backup job.
So I expect my script to be executed only if there's an error

Environment

  • Image version / tag: 4.1.4
  • Host OS: Linux

Possible fixes

I think it may be related to this log:

Found Custom Post Scripts in /assets/custom-scripts/ - Automatically moving them to '/assets/scripts/post/'
Executing post backup custom script : '/assets/scripts/post/backup-error-notifier.sh'

But i don't understand why it moves it to /assets/scripts/post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant