fix: backups
This commit is contained in:
@@ -289,7 +289,7 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
|
||||
if ($this->backup->save_s3) {
|
||||
$this->upload_to_s3();
|
||||
}
|
||||
$this->team?->notify(new BackupSuccess($this->backup, $this->database));
|
||||
$this->team?->notify(new BackupSuccess($this->backup, $this->database, $database));
|
||||
$this->backup_log->update([
|
||||
'status' => 'success',
|
||||
'message' => $this->backup_output,
|
||||
@@ -305,8 +305,7 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
|
||||
]);
|
||||
}
|
||||
send_internal_notification('DatabaseBackupJob failed with: ' . $e->getMessage());
|
||||
$this->team?->notify(new BackupFailed($this->backup, $this->database, $this->backup_output));
|
||||
throw $e;
|
||||
$this->team?->notify(new BackupFailed($this->backup, $this->database, $this->backup_output, $database));
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
@@ -57,7 +57,7 @@ class SendMessageToTelegramJob implements ShouldQueue, ShouldBeEncrypted
|
||||
}
|
||||
}
|
||||
$payload = [
|
||||
'parse_mode' => 'markdown',
|
||||
// 'parse_mode' => 'markdown',
|
||||
'reply_markup' => json_encode([
|
||||
'inline_keyboard' => [
|
||||
[...$inlineButtons],
|
||||
|
||||
@@ -35,11 +35,6 @@ class Execution extends Component
|
||||
$this->executions = $executions;
|
||||
$this->s3s = currentTeam()->s3s;
|
||||
}
|
||||
public function cleanupFailed()
|
||||
{
|
||||
$this->backup->executions()->where('status', 'failed')->delete();
|
||||
$this->dispatch('refreshBackupExecutions');
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.database.backup.execution');
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Livewire\Project\Database;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Component;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class BackupExecutions extends Component
|
||||
{
|
||||
@@ -16,11 +14,15 @@ class BackupExecutions extends Component
|
||||
$userId = auth()->user()->id;
|
||||
return [
|
||||
"echo-private:team.{$userId},BackupCreated" => 'refreshBackupExecutions',
|
||||
"refreshBackupExecutions",
|
||||
"deleteBackup"
|
||||
];
|
||||
}
|
||||
|
||||
public function cleanupFailed()
|
||||
{
|
||||
$this->backup->executions()->where('status', 'failed')->delete();
|
||||
$this->refreshBackupExecutions();
|
||||
}
|
||||
public function deleteBackup($exeuctionId)
|
||||
{
|
||||
$execution = $this->backup->executions()->where('id', $exeuctionId)->first();
|
||||
|
||||
@@ -207,7 +207,4 @@ class StandaloneClickhouse extends BaseModel
|
||||
{
|
||||
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
|
||||
}
|
||||
public function database_name() {
|
||||
return $this->clickhouse_db;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,4 @@ class StandaloneDragonfly extends BaseModel
|
||||
{
|
||||
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
|
||||
}
|
||||
public function database_name() {
|
||||
return '0';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,4 @@ class StandaloneKeydb extends BaseModel
|
||||
{
|
||||
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
|
||||
}
|
||||
public function database_name() {
|
||||
return '0';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,4 @@ class StandaloneMariadb extends BaseModel
|
||||
{
|
||||
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
|
||||
}
|
||||
public function database_name() {
|
||||
return $this->mariadb_database;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,4 @@ class StandaloneMongodb extends BaseModel
|
||||
{
|
||||
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
|
||||
}
|
||||
public function database_name() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,4 @@ class StandaloneMysql extends BaseModel
|
||||
{
|
||||
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
|
||||
}
|
||||
public function database_name() {
|
||||
return $this->mysql_database;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,4 @@ class StandalonePostgresql extends BaseModel
|
||||
{
|
||||
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
|
||||
}
|
||||
public function database_name() {
|
||||
return $this->postgres_db;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,4 @@ class StandaloneRedis extends BaseModel
|
||||
{
|
||||
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
|
||||
}
|
||||
public function database_name() {
|
||||
return '0';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,21 +15,20 @@ class BackupFailed extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public $tries = 1;
|
||||
public $backoff = 10;
|
||||
public $tries = 2;
|
||||
public string $name;
|
||||
public ?string $database_name = null;
|
||||
public string $frequency;
|
||||
|
||||
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $output)
|
||||
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $output, public $database_name)
|
||||
{
|
||||
$this->name = $database->name;
|
||||
$this->database_name = $database->database_name();
|
||||
$this->frequency = $backup->frequency;
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return [DiscordChannel::class, TelegramChannel::class, MailChannel::class];
|
||||
return setNotificationChannels($notifiable, 'database_backups');
|
||||
}
|
||||
|
||||
public function toMail(): MailMessage
|
||||
@@ -47,11 +46,11 @@ class BackupFailed extends Notification implements ShouldQueue
|
||||
|
||||
public function toDiscord(): string
|
||||
{
|
||||
return "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was FAILED.\n\nReason: {$this->output}";
|
||||
return "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was FAILED.\n\nReason:\n{$this->output}";
|
||||
}
|
||||
public function toTelegram(): array
|
||||
{
|
||||
$message = "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was FAILED.\n\nReason: {$this->output}";
|
||||
$message = "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was FAILED.\n\nReason:\n{$this->output}";
|
||||
return [
|
||||
"message" => $message,
|
||||
];
|
||||
|
||||
@@ -12,15 +12,14 @@ class BackupSuccess extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public $tries = 1;
|
||||
public $backoff = 10;
|
||||
public $tries = 3;
|
||||
public string $name;
|
||||
public ?string $database_name = null;
|
||||
public string $frequency;
|
||||
|
||||
public function __construct(ScheduledDatabaseBackup $backup, public $database)
|
||||
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $database_name)
|
||||
{
|
||||
$this->name = $database->name;
|
||||
$this->database_name = $database->database_name();
|
||||
$this->frequency = $backup->frequency;
|
||||
}
|
||||
|
||||
@@ -48,6 +47,7 @@ class BackupSuccess extends Notification implements ShouldQueue
|
||||
public function toTelegram(): array
|
||||
{
|
||||
$message = "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was successful.";
|
||||
ray($message);
|
||||
return [
|
||||
"message" => $message,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user