Skip to content

Receive SQLite backup alerts with a signed webhook

Receive firing and recovery events as JSON and check that Litebackup signed the exact bytes your endpoint received.

Connect an HTTPS receiver

  • Prepare the endpoint

    Accept POST requests at the final HTTPS URL. Hosted Litebackup requires a public address and does not follow redirects. For signed requests, store the same secret on the receiver and in Litebackup.

  • Connect Litebackup

    As an admin, open Alerts and choose Add destination. Select Generic HTTPS webhook and name the destination. Enter the endpoint in HTTPS URL. For HMAC, add a Signing secret. If the receiver requires Authorization, enter the complete header value, including its scheme. Choose Add destination to save it.

Generic HTTPS webhook selected with fields for the endpoint, optional signing secret and Authorization header. Generic HTTPS webhook selected with fields for the endpoint, optional signing secret and Authorization header.

Verify the signature before parsing JSON

Pass the secret as UTF-8 bytes, the raw request body and the Litebackup-Signature header to this Python function.

import hmac
import re
import time


def valid_signature(secret: bytes, body: bytes, signature: str) -> bool:
    match = re.fullmatch(r"t=([0-9]{1,12}),v1=([0-9a-f]{64})", signature)
    if match is None:
        return False
    timestamp, received = match.groups()
    if abs(time.time() - int(timestamp)) > 300:
        return False
    signed_body = timestamp.encode("ascii") + b"." + body
    expected = hmac.digest(secret, signed_body, "sha256").hex()
    return hmac.compare_digest(expected, received)

Check the signature

Read the body once as bytes. Pass an empty string to the verifier if the header is missing, and reject the request if verification fails. The signed bytes are the ASCII timestamp, a period and the exact body as received. Parsing and serializing JSON first can change the bytes. The example checks the lowercase HMAC-SHA256 digest in constant time and allows five minutes of clock difference.

Match the test requests by incident ID

On the Alerts page, choose Send test alert in the destination’s controls. The test can page a person. Check that both the trigger and recovery were accepted.

Check the receiver for two JSON bodies with test set to true. The first carries alert_firing and the second carries alert_resolved, a recovery timestamp and the same incident_id.

Accept retries without reopening an incident

Use the pair incident_id and event to recognize repeated requests. Save the event before returning a 2xx response. If an earlier trigger timed out, recovery can be the first event the receiver sees. Record it as resolved. An incident that ends before Litebackup even attempts the trigger stays in the server’s alert history.

Enable alerts

Check how many alerts are firing before choosing Enable delivery. Each server sends its open alerts immediately, then reports new alerts and recoveries for all enabled thresholds.

Install

Install Litebackup and back up a SQLite database to start monitoring it. Choose another paging service or chat channel in the alert integrations guide.