chore: fix infinity calling Fatal, add a backup reference

This commit is contained in:
Jonas Kaninda
2024-10-10 04:14:42 +02:00
parent df490af7b6
commit e5dd7e76ce
9 changed files with 133 additions and 59 deletions

View File

@@ -4,10 +4,10 @@ layout: default
parent: How Tos
nav_order: 12
---
Send Email or Telegram notifications on success or failed backup.
Send Email or Telegram notifications on successfully or failed backup.
### Email
To send out email notifications on failed backup runs, provide SMTP credentials, a sender and a recipient:
To send out email notifications on failed or successfully backup runs, provide SMTP credentials, a sender and a recipient:
```yaml
services:
@@ -27,9 +27,13 @@ services:
- MAIL_PORT=587
- MAIL_USERNAME=
- MAIL_PASSWORD=!
- MAIL_FROM=sender@example.com
- MAIL_FROM=
- MAIL_TO=me@example.com,team@example.com,manager@example.com
- MAIL_SKIP_TLS=false
## Time format for notification
- TIME_FORMAT=2006-01-02 at 15:04:05
## Backup reference, in case you want to identifier every backup instance
- BACKUP_REFERENCE=database/Paris cluster
networks:
- web
networks:
@@ -54,6 +58,10 @@ services:
- DB_PASSWORD=password
- TG_TOKEN=[BOT ID]:[BOT TOKEN]
- TG_CHAT_ID=
## Time format for notification
- TIME_FORMAT=2006-01-02 at 15:04:05
## Backup reference, in case you want to identifier every backup instance
- BACKUP_REFERENCE=database/Paris cluster
networks:
- web
networks:
@@ -62,12 +70,13 @@ networks:
### Customize notifications
The body of the notifications can be tailored to your needs using Go templates.
The title and body of the notifications can be tailored to your needs using Go templates.
Template sources must be mounted inside the container in /config/templates:
- email.template: Email notification template
- telegram.template: Telegram notification template
- error.template: Error notification template
- email-error.template: Error notification template
- telegram-error.template: Error notification template
### Data
@@ -78,7 +87,7 @@ Here is a list of all data passed to the template:
- `Storage`: Backup storage
- `BackupLocation`: Backup location
- `BackupSize`: Backup size
- `BackupReference`: Backup reference(eg: database/cluster name or server name)
> email.template:
@@ -88,19 +97,20 @@ Here is a list of all data passed to the template:
<html lang="en">
<head>
<meta charset="UTF-8">
<title>[✅ Database Backup Notification {{.Database}}</title>
<title>✅ Database Backup Notification {{.Database}}</title>
</head>
<body>
<h2>Hi,</h2>
<p>Backup of the {{.Database}} database has been successfully completed on {{.EndTime}}.</p>
<h3>Backup Details:</h3>
<ul>
<li>Database Name: {{.Database}}</li>
<li>Backup Start Time: {{.StartTime}}</li>
<li>Backup End Time: {{.EndTime}}</li>
<li>Backup Storage: {{.Storage}}</li>
<li>Backup Location: {{.BackupLocation}}</li>
<li>Backup Size: {{.BackupSize}} bytes</li>
<li>Database Name: {{.Database}}</li>
<li>Backup Start Time: {{.StartTime}}</li>
<li>Backup End Time: {{.EndTime}}</li>
<li>Backup Storage: {{.Storage}}</li>
<li>Backup Location: {{.BackupLocation}}</li>
<li>Backup Size: {{.BackupSize}} bytes</li>
<li>Backup Reference: {{.BackupReference}} </li>
</ul>
<p>Best regards,</p>
</body>
@@ -110,7 +120,7 @@ Here is a list of all data passed to the template:
> telegram.template
```html
[✅ Database Backup Notification {{.Database}}
✅ Database Backup Notification {{.Database}}
Hi,
Backup of the {{.Database}} database has been successfully completed on {{.EndTime}}.
@@ -121,9 +131,32 @@ Backup Details:
- Backup Storage: {{.Storage}}
- Backup Location: {{.BackupLocation}}
- Backup Size: {{.BackupSize}} bytes
- Backup Reference: {{.BackupReference}}
```
> error.template
> email-error.template
```html
<!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: {{.Error}}</li>
<li>Date: {{.EndTime}}</li>
<li>Backup Reference: {{.BackupReference}} </li>
</ul>
</body>
</html>
```
> telegram-error.template
```html