feat(notifcations): use just the coolify database name in notifications

- no longer use the cluster database_name in backup notifications as we always backup all databases
This commit is contained in:
peaklabs-dev 2026-02-03 00:27:08 +01:00
parent dc04b78631
commit f9958d83dc
No known key found for this signature in database
8 changed files with 57 additions and 54 deletions

View file

@ -54,7 +54,6 @@ class Emails extends Command
options: [
'updates' => 'Send Update Email to all users',
'emails-test' => 'Test',
'database-backup-statuses-daily' => 'Database - Backup Statuses (Daily)',
'application-deployment-success-daily' => 'Application - Deployment Success (Daily)',
'application-deployment-success' => 'Application - Deployment Success',
'application-deployment-failed' => 'Application - Deployment Failed',
@ -167,7 +166,7 @@ class Emails extends Command
]);
}
$output = 'Because of an error, the backup of the database '.$db->name.' failed.';
$this->mail = (new BackupFailed($backup, $db, $output, $backup->database_name ?? 'unknown'))->toMail();
$this->mail = (new BackupFailed($backup, $db, $output))->toMail();
$this->sendEmail();
break;
case 'backup-success':

View file

@ -15,7 +15,7 @@ class BackupFailed extends CustomEmailNotification
public string $frequency;
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $output, public $database_name)
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $output)
{
$this->onQueue('high');
$this->name = $database->name;
@ -33,7 +33,6 @@ class BackupFailed extends CustomEmailNotification
$mail->subject("Coolify: [ACTION REQUIRED] Database Backup FAILED for {$this->database->name}");
$mail->view('emails.backup-failed', [
'name' => $this->name,
'database_name' => $this->database_name,
'frequency' => $this->frequency,
'output' => $this->output,
]);
@ -45,7 +44,7 @@ class BackupFailed extends CustomEmailNotification
{
$message = new DiscordMessage(
title: ':cross_mark: Database backup failed',
description: "Database backup for {$this->name} (db:{$this->database_name}) has FAILED.",
description: "Database backup for {$this->name} has FAILED.",
color: DiscordMessage::errorColor(),
isCritical: true,
);
@ -58,7 +57,7 @@ class BackupFailed extends CustomEmailNotification
public function toTelegram(): array
{
$message = "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was FAILED.\n\nReason:\n{$this->output}";
$message = "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} was FAILED.\n\nReason:\n{$this->output}";
return [
'message' => $message,
@ -70,14 +69,14 @@ class BackupFailed extends CustomEmailNotification
return new PushoverMessage(
title: 'Database backup failed',
level: 'error',
message: "Database backup for {$this->name} (db:{$this->database_name}) was FAILED<br/><br/><b>Frequency:</b> {$this->frequency} .<br/><b>Reason:</b> {$this->output}",
message: "Database backup for {$this->name} was FAILED<br/><br/><b>Frequency:</b> {$this->frequency} .<br/><b>Reason:</b> {$this->output}",
);
}
public function toSlack(): SlackMessage
{
$title = 'Database backup failed';
$description = "Database backup for {$this->name} (db:{$this->database_name}) has FAILED.";
$description = "Database backup for {$this->name} has FAILED.";
$description .= "\n\n*Frequency:* {$this->frequency}";
$description .= "\n\n*Error Output:* {$this->output}";
@ -99,7 +98,6 @@ class BackupFailed extends CustomEmailNotification
'event' => 'backup_failed',
'database_name' => $this->name,
'database_uuid' => $this->database->uuid,
'database_type' => $this->database_name,
'frequency' => $this->frequency,
'error_output' => $this->output,
'url' => $url,

View file

@ -15,7 +15,7 @@ class BackupSuccess extends CustomEmailNotification
public string $frequency;
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $database_name)
public function __construct(ScheduledDatabaseBackup $backup, public $database)
{
$this->onQueue('high');
@ -34,7 +34,6 @@ class BackupSuccess extends CustomEmailNotification
$mail->subject("Coolify: Backup successfully done for {$this->database->name}");
$mail->view('emails.backup-success', [
'name' => $this->name,
'database_name' => $this->database_name,
'frequency' => $this->frequency,
]);
@ -45,7 +44,7 @@ class BackupSuccess extends CustomEmailNotification
{
$message = new DiscordMessage(
title: ':white_check_mark: Database backup successful',
description: "Database backup for {$this->name} (db:{$this->database_name}) was successful.",
description: "Database backup for {$this->name} was successful.",
color: DiscordMessage::successColor(),
);
@ -56,7 +55,7 @@ class BackupSuccess extends CustomEmailNotification
public function toTelegram(): array
{
$message = "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was successful.";
$message = "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} was successful.";
return [
'message' => $message,
@ -68,14 +67,14 @@ class BackupSuccess extends CustomEmailNotification
return new PushoverMessage(
title: 'Database backup successful',
level: 'success',
message: "Database backup for {$this->name} (db:{$this->database_name}) was successful.<br/><br/><b>Frequency:</b> {$this->frequency}.",
message: "Database backup for {$this->name} was successful.<br/><br/><b>Frequency:</b> {$this->frequency}.",
);
}
public function toSlack(): SlackMessage
{
$title = 'Database backup successful';
$description = "Database backup for {$this->name} (db:{$this->database_name}) was successful.";
$description = "Database backup for {$this->name} was successful.";
$description .= "\n\n*Frequency:* {$this->frequency}";
@ -96,7 +95,6 @@ class BackupSuccess extends CustomEmailNotification
'event' => 'backup_success',
'database_name' => $this->name,
'database_uuid' => $this->database->uuid,
'database_type' => $this->database_name,
'frequency' => $this->frequency,
'url' => $url,
];

View file

@ -17,7 +17,7 @@ class BackupSuccessWithS3Warning extends CustomEmailNotification
public ?string $s3_storage_url = null;
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $database_name, public $s3_error)
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $s3_error)
{
$this->onQueue('high');
@ -40,7 +40,6 @@ class BackupSuccessWithS3Warning extends CustomEmailNotification
$mail->subject("Coolify: Backup succeeded locally but S3 upload failed for {$this->database->name}");
$mail->view('emails.backup-success-with-s3-warning', [
'name' => $this->name,
'database_name' => $this->database_name,
'frequency' => $this->frequency,
's3_error' => $this->s3_error,
's3_storage_url' => $this->s3_storage_url,
@ -53,7 +52,7 @@ class BackupSuccessWithS3Warning extends CustomEmailNotification
{
$message = new DiscordMessage(
title: ':warning: Database backup succeeded locally, S3 upload failed',
description: "Database backup for {$this->name} (db:{$this->database_name}) was created successfully on local storage, but failed to upload to S3.",
description: "Database backup for {$this->name} was created successfully on local storage, but failed to upload to S3.",
color: DiscordMessage::warningColor(),
);
@ -69,7 +68,7 @@ class BackupSuccessWithS3Warning extends CustomEmailNotification
public function toTelegram(): array
{
$message = "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} succeeded locally but failed to upload to S3.\n\nS3 Error:\n{$this->s3_error}";
$message = "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} succeeded locally but failed to upload to S3.\n\nS3 Error:\n{$this->s3_error}";
if ($this->s3_storage_url) {
$message .= "\n\nCheck S3 Configuration: {$this->s3_storage_url}";
@ -82,7 +81,7 @@ class BackupSuccessWithS3Warning extends CustomEmailNotification
public function toPushover(): PushoverMessage
{
$message = "Database backup for {$this->name} (db:{$this->database_name}) was created successfully on local storage, but failed to upload to S3.<br/><br/><b>Frequency:</b> {$this->frequency}.<br/><b>S3 Error:</b> {$this->s3_error}";
$message = "Database backup for {$this->name} was created successfully on local storage, but failed to upload to S3.<br/><br/><b>Frequency:</b> {$this->frequency}.<br/><b>S3 Error:</b> {$this->s3_error}";
if ($this->s3_storage_url) {
$message .= "<br/><br/><a href=\"{$this->s3_storage_url}\">Check S3 Configuration</a>";
@ -98,7 +97,7 @@ class BackupSuccessWithS3Warning extends CustomEmailNotification
public function toSlack(): SlackMessage
{
$title = 'Database backup succeeded locally, S3 upload failed';
$description = "Database backup for {$this->name} (db:{$this->database_name}) was created successfully on local storage, but failed to upload to S3.";
$description = "Database backup for {$this->name} was created successfully on local storage, but failed to upload to S3.";
$description .= "\n\n*Frequency:* {$this->frequency}";
$description .= "\n\n*S3 Error:* {$this->s3_error}";
@ -124,7 +123,6 @@ class BackupSuccessWithS3Warning extends CustomEmailNotification
'event' => 'backup_success_with_s3_warning',
'database_name' => $this->name,
'database_uuid' => $this->database->uuid,
'database_type' => $this->database_name,
'frequency' => $this->frequency,
's3_error' => $this->s3_error,
'url' => $url,

View file

@ -1,5 +1,5 @@
<x-emails.layout>
Database backup for {{ $name }} @if($database_name)(db:{{ $database_name }})@endif with frequency of {{ $frequency }} was FAILED.
Database backup for {{ $name }} with frequency of {{ $frequency }} was FAILED.
### Reason

View file

@ -1,5 +1,5 @@
<x-emails.layout>
Database backup for {{ $name }} @if($database_name)(db:{{ $database_name }})@endif with frequency of {{ $frequency }} succeeded locally but failed to upload to S3.
Database backup for {{ $name }} with frequency of {{ $frequency }} succeeded locally but failed to upload to S3.
S3 Error: {{ $s3_error }}

View file

@ -1,3 +1,3 @@
<x-emails.layout>
Database backup for {{ $name }} @if($database_name)(db:{{ $database_name }})@endif with frequency of {{ $frequency }} was successful.
Database backup for {{ $name }} with frequency of {{ $frequency }} was successful.
</x-emails.layout>

View file

@ -61,39 +61,49 @@
@if (str($resourceStatus)->startsWith('running'))
{{-- Restore Command Configuration --}}
@if ($resourceDbType === 'standalone-postgresql')
@if ($dumpAll)
<x-forms.textarea rows="6" readonly label="Custom Import Command"
wire:model='restoreCommandText'></x-forms.textarea>
@else
<x-forms.input label="Custom Import Command" wire:model='postgresqlRestoreCommand'></x-forms.input>
<div class="flex flex-col gap-1 pt-1">
<span class="text-xs">You can add "--clean" to drop objects before creating them, avoiding
conflicts.</span>
<span class="text-xs">You can add "--verbose" to log more things.</span>
<div class="flex flex-col gap-2 pt-4">
<h3>Import Options</h3>
<div class="flex flex-col gap-1 w-96">
<x-forms.checkbox label="Legacy Import All (complex restore with DB cleanup)" wire:model.live='legacyImportAll'
helper="Uses advanced restore that drops all databases, terminates connections, and restores. Use this for pg_dump custom format backups from older versions."></x-forms.checkbox>
<x-forms.checkbox label="Legacy Single DB (pg_restore)" wire:model.live='legacySingleDb'
helper="Uses pg_restore for single database custom format (.dmp) backups."></x-forms.checkbox>
</div>
@endif
<div class="w-64 pt-2">
<x-forms.checkbox label="Backup includes all databases" wire:model.live='dumpAll'></x-forms.checkbox>
<x-forms.input label="Restore Command" wire:model='postgresqlRestoreCommand'
helper="Default uses psql to restore from pg_dumpall backups. Modify if needed."></x-forms.input>
@if ($restoreCommandText)
<div class="text-xs text-neutral-500">{{ $restoreCommandText }}</div>
@endif
</div>
@elseif ($resourceDbType === 'standalone-mysql')
@if ($dumpAll)
<x-forms.textarea rows="14" readonly label="Custom Import Command"
wire:model='restoreCommandText'></x-forms.textarea>
@else
<x-forms.input label="Custom Import Command" wire:model='mysqlRestoreCommand'></x-forms.input>
@endif
<div class="w-64 pt-2">
<x-forms.checkbox label="Backup includes all databases" wire:model.live='dumpAll'></x-forms.checkbox>
<div class="flex flex-col gap-2 pt-4">
<h3>Import Options</h3>
<div class="flex flex-col gap-1 w-96">
<x-forms.checkbox label="Legacy Import All (complex restore with DB cleanup)" wire:model.live='legacyImportAll'
helper="Uses advanced restore that drops all databases, terminates connections, and restores. Use for older backup formats."></x-forms.checkbox>
<x-forms.checkbox label="Legacy Single DB (mysql with credentials)" wire:model.live='legacySingleDb'
helper="Uses mysql command with user credentials for single database backups."></x-forms.checkbox>
</div>
<x-forms.input label="Restore Command" wire:model='mysqlRestoreCommand'
helper="Default restores from mysqldump --all-databases backups. Modify if needed."></x-forms.input>
@if ($restoreCommandText)
<div class="text-xs text-neutral-500">{{ $restoreCommandText }}</div>
@endif
</div>
@elseif ($resourceDbType === 'standalone-mariadb')
@if ($dumpAll)
<x-forms.textarea rows="14" readonly label="Custom Import Command"
wire:model='restoreCommandText'></x-forms.textarea>
@else
<x-forms.input label="Custom Import Command" wire:model='mariadbRestoreCommand'></x-forms.input>
@endif
<div class="w-64 pt-2">
<x-forms.checkbox label="Backup includes all databases" wire:model.live='dumpAll'></x-forms.checkbox>
<div class="flex flex-col gap-2 pt-4">
<h3>Import Options</h3>
<div class="flex flex-col gap-1 w-96">
<x-forms.checkbox label="Legacy Import All (complex restore with DB cleanup)" wire:model.live='legacyImportAll'
helper="Uses advanced restore that drops all databases, terminates connections, and restores. Use for older backup formats."></x-forms.checkbox>
<x-forms.checkbox label="Legacy Single DB (mariadb with credentials)" wire:model.live='legacySingleDb'
helper="Uses mariadb command with user credentials for single database backups."></x-forms.checkbox>
</div>
<x-forms.input label="Restore Command" wire:model='mariadbRestoreCommand'
helper="Default restores from mariadb-dump --all-databases backups. Modify if needed."></x-forms.input>
@if ($restoreCommandText)
<div class="text-xs text-neutral-500">{{ $restoreCommandText }}</div>
@endif
</div>
@endif