mirror of
https://github.com/jkaninda/mysql-bkup.git
synced 2025-12-06 21:49:40 +01:00
chore: update notification template
This commit is contained in:
@@ -72,6 +72,8 @@ func testDatabaseConnection(db *dbConfig) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.Info("Connecting to %s database ...", db.dbName)
|
utils.Info("Connecting to %s database ...", db.dbName)
|
||||||
|
// Set database name for notification error
|
||||||
|
utils.DatabaseName = db.dbName
|
||||||
cmd := exec.Command("mysql", "-h", db.dbHost, "-P", db.dbPort, "-u", db.dbUserName, db.dbName, "-e", "quit")
|
cmd := exec.Command("mysql", "-h", db.dbHost, "-P", db.dbPort, "-u", db.dbUserName, db.dbName, "-e", "quit")
|
||||||
// Capture the output
|
// Capture the output
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
|
|||||||
@@ -1,18 +1,69 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>🔴 Urgent: Database Backup Failure Notification</title>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>🔴 Urgent: Database Backup Failure</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
color: #333;
|
||||||
|
margin: 0;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
color: #d9534f;
|
||||||
|
}
|
||||||
|
.details {
|
||||||
|
background-color: #ffffff;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
padding: 15px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.details ul {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.details li {
|
||||||
|
margin: 5px 0;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
color: #0275d8;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
margin-top: 20px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h2>Hi,</h2>
|
<h2>🔴 Urgent: Database Backup Failure Notification</h2>
|
||||||
<p>An error occurred during database backup.</p>
|
<p>Dear Team,</p>
|
||||||
<h3>Failure Details:</h3>
|
<p>An error occurred during the database backup process. Please review the details below and take the necessary actions:</p>
|
||||||
<ul>
|
|
||||||
<li>Error Message: {{.Error}}</li>
|
<div class="details">
|
||||||
<li>Date: {{.EndTime}}</li>
|
<h3>Failure Details:</h3>
|
||||||
<li>Backup Reference: {{.BackupReference}} </li>
|
<ul>
|
||||||
</ul>
|
<li><strong>Database Name:</strong> {{.DatabaseName}}</li>
|
||||||
<p>©2024 <a href="https://github.com/jkaninda/mysql-bkup">mysql-bkup</a></p>
|
<li><strong>Error Message:</strong> {{.Error}}</li>
|
||||||
|
<li><strong>Date:</strong> {{.EndTime}}</li>
|
||||||
|
<li><strong>Backup Reference:</strong> {{.BackupReference}}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>We recommend investigating the issue as soon as possible to prevent potential data loss or service disruptions.</p>
|
||||||
|
|
||||||
|
<p>For more information, visit the <a href="https://jkaninda.github.io/pg-bkup">pg-bkup documentation</a>.</p>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
© 2024 <a href="https://github.com/jkaninda/pg-bkup">pg-bkup</a> | Automated Backup System
|
||||||
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,24 +1,70 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>✅ Database Backup Notification – {{.Database}}</title>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>✅ Database Backup Successful – {{.Database}}</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
color: #333;
|
||||||
|
margin: 0;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
color: #5cb85c;
|
||||||
|
}
|
||||||
|
.details {
|
||||||
|
background-color: #ffffff;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
padding: 15px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.details ul {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.details li {
|
||||||
|
margin: 5px 0;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
color: #0275d8;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
margin-top: 20px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h2>Hi,</h2>
|
<h2>✅ Database Backup Successful</h2>
|
||||||
<p>Backup of the {{.Database}} database has been successfully completed on {{.EndTime}}.</p>
|
<p>Dear Team,</p>
|
||||||
<h3>Backup Details:</h3>
|
<p>The backup process for the <strong>{{.Database}}</strong> database was successfully completed. Please find the details below:</p>
|
||||||
<ul>
|
|
||||||
<li>Database Name: {{.Database}}</li>
|
<div class="details">
|
||||||
<li>Backup Start Time: {{.StartTime}}</li>
|
<h3>Backup Details:</h3>
|
||||||
<li>Backup End Time: {{.EndTime}}</li>
|
<ul>
|
||||||
<li>Backup Storage: {{.Storage}}</li>
|
<li><strong>Database Name:</strong> {{.Database}}</li>
|
||||||
<li>Backup Location: {{.BackupLocation}}</li>
|
<li><strong>Backup Start Time:</strong> {{.StartTime}}</li>
|
||||||
<li>Backup Size: {{.BackupSize}} bytes</li>
|
<li><strong>Backup End Time:</strong> {{.EndTime}}</li>
|
||||||
<li>Backup Reference: {{.BackupReference}} </li>
|
<li><strong>Backup Storage:</strong> {{.Storage}}</li>
|
||||||
</ul>
|
<li><strong>Backup Location:</strong> {{.BackupLocation}}</li>
|
||||||
<p>Best regards,</p>
|
<li><strong>Backup Size:</strong> {{.BackupSize}} bytes</li>
|
||||||
<p>©2024 <a href="https://github.com/jkaninda/mysql-bkup">mysql-bkup</a></p>
|
<li><strong>Backup Reference:</strong> {{.BackupReference}}</li>
|
||||||
<href>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>You can access the backup at the specified location if needed. Thank you for using <a href="https://jkaninda.github.io/mysql-bkup/">mysql-bkup</a>.</p>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
© 2024 <a href="https://github.com/jkaninda/mysql-bkup">mysql-bkup</a> | Automated Backup System
|
||||||
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
🔴 Urgent: Database Backup Failure Notification
|
🔴 Urgent: Database Backup Failure Notification
|
||||||
Hi,
|
|
||||||
An error occurred during database backup.
|
Dear Team,
|
||||||
|
An error occurred during the database backup process.
|
||||||
|
Please review the details below and take the necessary actions:
|
||||||
Failure Details:
|
Failure Details:
|
||||||
|
- Database Name: {{.DatabaseName}}
|
||||||
- Date: {{.EndTime}}
|
- Date: {{.EndTime}}
|
||||||
- Backup Reference: {{.BackupReference}}
|
- Backup Reference: {{.BackupReference}}
|
||||||
- Error Message: {{.Error}}
|
- Error Message: {{.Error}}
|
||||||
|
We recommend investigating the issue as soon as possible to prevent potential data loss or service disruptions.
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
[✅ Database Backup Notification – {{.Database}}
|
✅ Database Backup Successful
|
||||||
Hi,
|
|
||||||
Backup of the {{.Database}} database has been successfully completed on {{.EndTime}}.
|
Dear Team,
|
||||||
|
The backup process for the {{.Database}} database was successfully completed.
|
||||||
|
Please find the details below:
|
||||||
|
|
||||||
Backup Details:
|
Backup Details:
|
||||||
- Database Name: {{.Database}}
|
- Database Name: {{.Database}}
|
||||||
@@ -10,3 +12,5 @@ Backup Details:
|
|||||||
- Backup Location: {{.BackupLocation}}
|
- Backup Location: {{.BackupLocation}}
|
||||||
- Backup Size: {{.BackupSize}} bytes
|
- Backup Size: {{.BackupSize}} bytes
|
||||||
- Backup Reference: {{.BackupReference}}
|
- Backup Reference: {{.BackupReference}}
|
||||||
|
|
||||||
|
You can access the backup at the specified location if needed.
|
||||||
@@ -50,6 +50,7 @@ type ErrorMessage struct {
|
|||||||
EndTime string
|
EndTime string
|
||||||
Error string
|
Error string
|
||||||
BackupReference string
|
BackupReference string
|
||||||
|
DatabaseName string
|
||||||
}
|
}
|
||||||
|
|
||||||
// loadMailConfig gets mail environment variables and returns MailConfig
|
// loadMailConfig gets mail environment variables and returns MailConfig
|
||||||
@@ -81,3 +82,5 @@ func backupReference() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const templatePath = "/config/templates"
|
const templatePath = "/config/templates"
|
||||||
|
|
||||||
|
var DatabaseName = ""
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ func NotifyError(error string) {
|
|||||||
Error: error,
|
Error: error,
|
||||||
EndTime: time.Now().Format(TimeFormat()),
|
EndTime: time.Now().Format(TimeFormat()),
|
||||||
BackupReference: os.Getenv("BACKUP_REFERENCE"),
|
BackupReference: os.Getenv("BACKUP_REFERENCE"),
|
||||||
|
DatabaseName: DatabaseName,
|
||||||
}, "email-error.tmpl")
|
}, "email-error.tmpl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error("Could not parse error template: %v", err)
|
Error("Could not parse error template: %v", err)
|
||||||
@@ -183,6 +184,7 @@ func NotifyError(error string) {
|
|||||||
Error: error,
|
Error: error,
|
||||||
EndTime: time.Now().Format(TimeFormat()),
|
EndTime: time.Now().Format(TimeFormat()),
|
||||||
BackupReference: os.Getenv("BACKUP_REFERENCE"),
|
BackupReference: os.Getenv("BACKUP_REFERENCE"),
|
||||||
|
DatabaseName: DatabaseName,
|
||||||
}, "telegram-error.tmpl")
|
}, "telegram-error.tmpl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error("Could not parse error template: %v", err)
|
Error("Could not parse error template: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user