Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat(databases): implement unique UUID generation for backup execution

Andras Bacsai99b101507ce0
diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php
index 6ac9ae1e66..5c38d938f0 100644
--- a/app/Jobs/DatabaseBackupJob.php
+++ b/app/Jobs/DatabaseBackupJob.php
@@ -74,13 +74,21 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
{
$this->onQueue('high');
$this->timeout = $backup->timeout;
-
- $this->backup_log_uuid = (string) new Cuid2;
}
public function handle(): void
{
try {
+ $attempts = 0;
+ do {
+ $this->backup_log_uuid = (string) new Cuid2;
+ $exists = ScheduledDatabaseBackupExecution::where('uuid', $this->backup_log_uuid)->exists();
+ $attempts++;
+ if ($attempts >= 3 && $exists) {
+ throw new \Exception('Unable to generate unique UUID for backup execution after 3 attempts');
+ }
+ } while ($exists);
+
$databasesToBackup = null;
$this->team = Team::find($this->backup->team_id);