Receive Notifications
You can configure the system to send email (SMTP or Posta) or Telegram notifications when a backup succeeds or fails.
This section explains how to set up and customize notifications.
Email Notifications
To send email notifications, provide SMTP credentials, a sender address, and recipient addresses. Notifications will be sent for both successful and failed backup runs.
Example: Email Notification Configuration
services:
pg-bkup:
image: jkaninda/pg-bkup
container_name: pg-bkup
command: backup
volumes:
- ./backup:/backup
environment:
- DB_PORT=5432
- DB_HOST=postgres
- DB_NAME=database
- DB_USER=username
- DB_PASSWORD=password
## SMTP Configuration
- MAIL_HOST=smtp.example.com
- MAIL_PORT=587
- MAIL_USERNAME=your-email@example.com
- MAIL_PASSWORD=your-email-password
- MAIL_FROM=Backup Jobs <backup@example.com>
## Multiple recipients separated by a comma
- MAIL_TO=me@example.com,team@example.com,manager@example.com
## STARTTLS (default), tls or none; set MAIL_INSECURE_SKIP_VERIFY=true only for self-signed certificates
- MAIL_TLS=starttls
- MAIL_INSECURE_SKIP_VERIFY=false
## Time format for notifications
- TIME_FORMAT=2006-01-02 at 15:04:05
## Backup reference (e.g., database/cluster name or server name)
- BACKUP_REFERENCE=database/Paris cluster
networks:
- web
networks:
web:
Posta Notifications
Posta can deliver the notification emails instead of an SMTP server. Set the Posta URL, an API key with the send scope and the recipients. By default the same HTML email is sent (with a plain-text version). To use a template stored in Posta instead, set POSTA_TEMPLATE (and optionally POSTA_TEMPLATE_ERROR for failures); the notification fields (database, file, duration, storage, location, size, backup_size, sha256, encryption, error, time, success, tool…) are passed as template data.
Example: Posta Notification Configuration
services:
pg-bkup:
image: jkaninda/pg-bkup
container_name: pg-bkup
command: backup
volumes:
- ./backup:/backup
environment:
- DB_PORT=5432
- DB_HOST=db
- DB_NAME=database
- DB_USER=username
- DB_PASSWORD=password
## Posta
- POSTA_URL=https://posta.example.com
- POSTA_API_KEY=psk_your_api_key
- POSTA_FROM=Backup Jobs <backup@example.com>
## Multiple recipients separated by a comma (default MAIL_TO)
- POSTA_TO=me@example.com,team@example.com
## Optional: templates stored in Posta
#- POSTA_TEMPLATE=backup-success
#- POSTA_TEMPLATE_ERROR=backup-failure
#- POSTA_LANGUAGE=en
## Only for account-wide API keys
#- POSTA_WORKSPACE_ID=42
## Only notify failures
#- NOTIFY_ON=failure
Telegram Notifications
To send Telegram notifications, provide your bot token and chat ID. Notifications will be sent for both successful and failed backup runs.
Example: Telegram Notification Configuration
services:
pg-bkup:
image: jkaninda/pg-bkup
container_name: pg-bkup
command: backup
volumes:
- ./backup:/backup
environment:
- DB_PORT=5432
- DB_HOST=postgres
- DB_NAME=database
- DB_USER=username
- DB_PASSWORD=password
## Telegram Configuration
- TG_TOKEN=[BOT ID]:[BOT TOKEN]
- TG_CHAT_ID=your-chat-id
## Time format for notifications
- TIME_FORMAT=2006-01-02 at 15:04:05
## Backup reference (e.g., database/cluster name or server name)
- BACKUP_REFERENCE=database/Paris cluster
networks:
- web
networks:
web:
Customize Notifications
You can customize the title and body of notifications using Go templates. Template files must be mounted inside the container at /config/templates. The following templates are supported:
email.tmpl: Template for successful email notifications.telegram.tmpl(ortext.tmpl): Template for successful Telegram, Slack, Discord and ntfy notifications.email-error.tmpl: Template for failed email notifications.telegram-error.tmpl(ortext-error.tmpl): Template for failed Telegram, Slack, Discord and ntfy notifications.
Template Data
The following data is passed to the templates:
Database: Database name.StartTime: Backup start time.EndTime: Backup end time.Storage: Backup storage type (e.g., local, S3, SSH).BackupLocation: Backup file location.BackupSize: Backup file size in bytes.BackupReference: Backup reference (e.g., database/cluster name or server name).Error: Error message (only for error templates).
Example Templates
email.tmpl (Successful Backup)
<h2>Hi,</h2>
<p>Backup of the database has been successfully completed on .</p>
<h3>Backup Details:</h3>
<ul>
<li>Database Name: </li>
<li>Backup Start Time: </li>
<li>Backup End Time: </li>
<li>Backup Storage: </li>
<li>Backup Location: </li>
<li>Backup Size: bytes</li>
<li>Backup Reference: </li>
</ul>
<p>Best regards,</p>
telegram.tmpl (Successful Backup)
✅ Database Backup Notification –
Hi,
Backup of the database has been successfully completed on .
Backup Details:
- Database Name:
- Backup Start Time:
- Backup End Time:
- Backup Storage:
- Backup Location:
- Backup Size: bytes
- Backup Reference:
email-error.tmpl (Failed Backup)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>🔴 Urgent: Database Backup Failure Notification</title>
</head>
<body>
<h2>Hi,</h2>
<p>An error occurred during database backup.</p>
<h3>Failure Details:</h3>
<ul>
<li>Error Message: </li>
<li>Date: </li>
<li>Backup Reference: </li>
</ul>
</body>
</html>
telegram-error.tmpl (Failed Backup)
🔴 Urgent: Database Backup Failure Notification
An error occurred during database backup.
Failure Details:
Error Message:
Date:
Backup Reference:
Key Notes
- SMTP Configuration:
MAIL_TLSselectsstarttls(default),tlsornone; certificates are verified unlessMAIL_INSECURE_SKIP_VERIFY=true. The 1.xMAIL_SKIP_TLSis still read, now with its documented meaning (trueskips verification). - Other channels: Posta (
POSTA_*), Slack, Discord, ntfy, a generic webhook and healthchecks.io pings are also supported (SLACK_WEBHOOK_URL,DISCORD_WEBHOOK_URL,NTFY_URL,WEBHOOK_URL,HEALTHCHECK_PING_URL); see the configuration reference. - Telegram Configuration: Obtain your bot token and chat ID from Telegram.
- Custom Templates: Mount custom templates to
/config/templatesto override default notifications. - Time Format: Use the
TIME_FORMATenvironment variable to customize the timestamp format in notifications.