Add S3 storage to Livewire components and fix
backup job network issue
This commit is contained in:
parent
a7f9fad627
commit
18e98aaf52
@ -11,6 +11,7 @@ class ScheduledBackups extends Component
|
|||||||
public $type;
|
public $type;
|
||||||
public $selectedBackup;
|
public $selectedBackup;
|
||||||
public $selectedBackupId;
|
public $selectedBackupId;
|
||||||
|
public $s3s;
|
||||||
protected $listeners = ['refreshScheduledBackups'];
|
protected $listeners = ['refreshScheduledBackups'];
|
||||||
protected $queryString = ['selectedBackupId'];
|
protected $queryString = ['selectedBackupId'];
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ class ScheduledBackups extends Component
|
|||||||
} else {
|
} else {
|
||||||
$this->type = 'database';
|
$this->type = 'database';
|
||||||
}
|
}
|
||||||
|
$this->s3s = currentTeam()->s3s;
|
||||||
}
|
}
|
||||||
public function setSelectedBackup($backupId) {
|
public function setSelectedBackup($backupId) {
|
||||||
$this->selectedBackupId = $backupId;
|
$this->selectedBackupId = $backupId;
|
||||||
|
@ -16,6 +16,8 @@ class Show extends Component
|
|||||||
public array $parameters;
|
public array $parameters;
|
||||||
public array $query;
|
public array $query;
|
||||||
public Collection $services;
|
public Collection $services;
|
||||||
|
public $s3s;
|
||||||
|
|
||||||
protected $listeners = ['generateDockerCompose'];
|
protected $listeners = ['generateDockerCompose'];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@ -33,6 +35,7 @@ class Show extends Component
|
|||||||
$this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first();
|
$this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first();
|
||||||
$this->serviceDatabase->getFilesFromServer();
|
$this->serviceDatabase->getFilesFromServer();
|
||||||
}
|
}
|
||||||
|
$this->s3s = currentTeam()->s3s;
|
||||||
} catch(\Throwable $e) {
|
} catch(\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,6 @@ class Backup extends Component
|
|||||||
]);
|
]);
|
||||||
$this->database->refresh();
|
$this->database->refresh();
|
||||||
$this->backup->refresh();
|
$this->backup->refresh();
|
||||||
ray($this->backup);
|
|
||||||
$this->s3s = S3Storage::whereTeamId(0)->get();
|
$this->s3s = S3Storage::whereTeamId(0)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,8 +364,12 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
$bucket = $this->s3->bucket;
|
$bucket = $this->s3->bucket;
|
||||||
$endpoint = $this->s3->endpoint;
|
$endpoint = $this->s3->endpoint;
|
||||||
$this->s3->testConnection();
|
$this->s3->testConnection();
|
||||||
$commands[] = "docker run --pull=always -d --network {$this->database->destination->network} --name backup-of-{$this->backup->uuid} --rm -v $this->backup_location:$this->backup_location:ro ghcr.io/coollabsio/coolify-helper >/dev/null 2>&1";
|
if (data_get($this->backup, 'database_type') === 'App\Models\ServiceDatabase') {
|
||||||
|
$network = $this->database->service->destination->network;
|
||||||
|
} else {
|
||||||
|
$network = $this->database->destination->network;
|
||||||
|
}
|
||||||
|
$commands[] = "docker run --pull=always -d --network {$network} --name backup-of-{$this->backup->uuid} --rm -v $this->backup_location:$this->backup_location:ro ghcr.io/coollabsio/coolify-helper";
|
||||||
$commands[] = "docker exec backup-of-{$this->backup->uuid} mc config host add temporary {$endpoint} $key $secret";
|
$commands[] = "docker exec backup-of-{$this->backup->uuid} mc config host add temporary {$endpoint} $key $secret";
|
||||||
$commands[] = "docker exec backup-of-{$this->backup->uuid} mc cp $this->backup_location temporary/$bucket{$this->backup_dir}/";
|
$commands[] = "docker exec backup-of-{$this->backup->uuid} mc cp $this->backup_location temporary/$bucket{$this->backup_dir}/";
|
||||||
instant_remote_process($commands, $this->server);
|
instant_remote_process($commands, $this->server);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@if ($type === 'service-database' && $selectedBackup)
|
@if ($type === 'service-database' && $selectedBackup)
|
||||||
<div class="pt-10">
|
<div class="pt-10">
|
||||||
<livewire:project.database.backup-edit key="{{ $selectedBackup->id }}" :backup="$selectedBackup" :s3s="collect()"
|
<livewire:project.database.backup-edit key="{{ $selectedBackup->id }}" :backup="$selectedBackup" :s3s="$s3s"
|
||||||
:status="data_get($database, 'status')" />
|
:status="data_get($database, 'status')" />
|
||||||
<h3 class="py-4">Executions</h3>
|
<h3 class="py-4">Executions</h3>
|
||||||
<livewire:project.database.backup-executions key="{{ $selectedBackup->id }}" :backup="$selectedBackup"
|
<livewire:project.database.backup-executions key="{{ $selectedBackup->id }}" :backup="$selectedBackup"
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
<h2 class="pb-4">Scheduled Backups</h2>
|
<h2 class="pb-4">Scheduled Backups</h2>
|
||||||
<x-forms.button onclick="createScheduledBackup.showModal()">+ Add</x-forms.button>
|
<x-forms.button onclick="createScheduledBackup.showModal()">+ Add</x-forms.button>
|
||||||
</div>
|
</div>
|
||||||
<livewire:project.database.create-scheduled-backup :database="$serviceDatabase" :s3s="collect()" />
|
<livewire:project.database.create-scheduled-backup :database="$serviceDatabase" :s3s="$s3s" />
|
||||||
<livewire:project.database.scheduled-backups :database="$serviceDatabase" />
|
<livewire:project.database.scheduled-backups :database="$serviceDatabase" />
|
||||||
</div>
|
</div>
|
||||||
@endisset
|
@endisset
|
||||||
|
Loading…
x
Reference in New Issue
Block a user