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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: download local backups
Andras Bacsaid5cc2a2eedc6
diff --git a/app/Http/Livewire/Project/Database/BackupExecutions.php b/app/Http/Livewire/Project/Database/BackupExecutions.phpindex 2f808d9926..f8ec4efbe3 100644--- a/app/Http/Livewire/Project/Database/BackupExecutions.php+++ b/app/Http/Livewire/Project/Database/BackupExecutions.php@@ -2,6 +2,7 @@namespace App\Http\Livewire\Project\Database;+use Illuminate\Support\Facades\Storage;use Livewire\Component;class BackupExecutions extends Component@@ -23,6 +24,29 @@ class BackupExecutions extends Component$this->emit('success', 'Backup deleted successfully.');$this->emit('refreshBackupExecutions');}+ public function download($exeuctionId)+ {+ try {+ $execution = $this->backup->executions()->where('id', $exeuctionId)->first();+ if (is_null($execution)) {+ $this->emit('error', 'Backup execution not found.');+ return;+ }+ $filename = data_get($execution, 'filename');+ $server = $execution->scheduledDatabaseBackup->database->destination->server;+ $privateKeyLocation = savePrivateKeyToFs($server);+ $disk = Storage::build([+ 'driver' => 'sftp',+ 'host' => $server->ip,+ 'port' => $server->port,+ 'username' => $server->user,+ 'privateKey' => $privateKeyLocation,+ ]);+ return $disk->download($filename);+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }+ }public function refreshBackupExecutions(): void{$this->executions = $this->backup->executions;diff --git a/composer.json b/composer.jsonindex 217560b572..9937ee5b98 100644--- a/composer.json+++ b/composer.json@@ -21,6 +21,7 @@"laravel/ui": "^4.2","lcobucci/jwt": "^5.0.0","league/flysystem-aws-s3-v3": "^3.0",+ "league/flysystem-sftp-v3": "^3.0","livewire/livewire": "^v2.12.3","lorisleiva/laravel-actions": "^2.7","masmerise/livewire-toaster": "^1.2",diff --git a/composer.lock b/composer.lockindex 9f9e8d658a..62d4f27ff0 100644--- a/composer.lock+++ b/composer.lock@@ -4,7 +4,7 @@"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies","This file is @generated automatically"],- "content-hash": "de2c45be3f03d43430549d963778dc4a",+ "content-hash": "21ed976753483557403be75318585442","packages": [{"name": "aws/aws-crt-php",@@ -2938,6 +2938,66 @@],"time": "2023-08-30T10:23:59+00:00"},+ {+ "name": "league/flysystem-sftp-v3",+ "version": "3.16.0",+ "source": {+ "type": "git",+ "url": "https://github.com/thephpleague/flysystem-sftp-v3.git",+ "reference": "1ba682def8e87fd7fa00883629553c0200d2e974"+ },+ "dist": {+ "type": "zip",+ "url": "https://api.github.com/repos/thephpleague/flysystem-sftp-v3/zipball/1ba682def8e87fd7fa00883629553c0200d2e974",+ "reference": "1ba682def8e87fd7fa00883629553c0200d2e974",+ "shasum": ""+ },+ "require": {+ "league/flysystem": "^3.0.14",+ "league/mime-type-detection": "^1.0.0",+ "php": "^8.0.2",+ "phpseclib/phpseclib": "^3.0"+ },+ "type": "library",+ "autoload": {+ "psr-4": {+ "League\\Flysystem\\PhpseclibV3\\": ""+ }+ },+ "notification-url": "https://packagist.org/downloads/",+ "license": [+ "MIT"+ ],+ "authors": [+ {+ "name": "Frank de Jonge",+ "email": "[email protected]"+ }+ ],+ "description": "SFTP filesystem adapter for Flysystem.",+ "keywords": [+ "Flysystem",+ "file",+ "files",+ "filesystem",+ "sftp"+ ],+ "support": {+ "issues": "https://github.com/thephpleague/flysystem-sftp-v3/issues",+ "source": "https://github.com/thephpleague/flysystem-sftp-v3/tree/3.16.0"+ },+ "funding": [+ {+ "url": "https://ecologi.com/frankdejonge",+ "type": "custom"+ },+ {+ "url": "https://github.com/frankdejonge",+ "type": "github"+ }+ ],+ "time": "2023-08-30T10:25:05+00:00"+ },{"name": "league/mime-type-detection","version": "1.13.0",diff --git a/config/sentry.php b/config/sentry.phpindex 32e27e0814..16f1842296 100644--- a/config/sentry.php+++ b/config/sentry.php@@ -7,7 +7,7 @@ return [// The release version of your application// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))- 'release' => '4.0.0-beta.101',+ 'release' => '4.0.0-beta.102',// When left empty or `null` the Laravel environment will be used'environment' => config('app.env'),diff --git a/config/version.php b/config/version.phpindex d540645790..004c77c3bb 100644--- a/config/version.php+++ b/config/version.php@@ -1,3 +1,3 @@<?php-return '4.0.0-beta.101';+return '4.0.0-beta.102';diff --git a/resources/views/livewire/project/database/backup-executions.blade.php b/resources/views/livewire/project/database/backup-executions.blade.phpindex 7b0a2ca51a..55bc2919aa 100644--- a/resources/views/livewire/project/database/backup-executions.blade.php+++ b/resources/views/livewire/project/database/backup-executions.blade.php@@ -17,10 +17,10 @@<div>Location: {{ data_get($execution, 'filename', 'N/A') }}</div><div class="flex gap-2"><div class="flex-1"></div>-- {{-- @if (data_get($execution, 'status') !== 'failed') --}}- {{-- <x-forms.button class="bg-coollabs-100 hover:bg-coollabs" wire:click="download">Download</x-forms.button> --}}- {{-- @endif --}}+ @if (data_get($execution, 'status') === 'success')+ <x-forms.button class=" hover:bg-coolgray-400"+ wire:click="download({{ data_get($execution, 'id') }})">Download</x-forms.button>+ @endif<x-forms.button isError onclick="sure({{ data_get($execution, 'id') }})">Delete</x-forms.button></div></form>diff --git a/versions.json b/versions.jsonindex 4c8e06b9d5..cd5da11104 100644--- a/versions.json+++ b/versions.json@@ -4,7 +4,7 @@"version": "3.12.36"},"v4": {- "version": "4.0.0-beta.101"+ "version": "4.0.0-beta.102"}}}