diff --git a/app/Enums/StorageProvider.php b/app/Enums/StorageProvider.php index 4fb8c89..84c2275 100644 --- a/app/Enums/StorageProvider.php +++ b/app/Enums/StorageProvider.php @@ -7,4 +7,6 @@ final class StorageProvider const DROPBOX = 'dropbox'; const FTP = 'ftp'; + + const LOCAL = 'local'; } diff --git a/app/Http/Controllers/DatabaseBackupController.php b/app/Http/Controllers/DatabaseBackupController.php index 770cbb2..6695001 100644 --- a/app/Http/Controllers/DatabaseBackupController.php +++ b/app/Http/Controllers/DatabaseBackupController.php @@ -78,6 +78,13 @@ public function destroyFile(Server $server, Backup $backup, BackupFile $backupFi $backupFile->delete(); + $backupFile + ->backup + ->storage + ->provider() + ->ssh($server) + ->delete($backupFile->storagePath()); + Toast::success('Backup file deleted successfully.'); return back(); diff --git a/app/SSH/Services/Database/AbstractDatabase.php b/app/SSH/Services/Database/AbstractDatabase.php index 12fd55f..148d4cb 100755 --- a/app/SSH/Services/Database/AbstractDatabase.php +++ b/app/SSH/Services/Database/AbstractDatabase.php @@ -159,7 +159,7 @@ public function runBackup(BackupFile $backupFile): void ); // cleanup - $this->service->server->ssh()->exec('rm '.$backupFile->name.'.zip'); + $this->service->server->ssh()->exec('rm '.$backupFile->path()); $backupFile->size = $upload['size']; $backupFile->save(); diff --git a/app/SSH/Storage/Dropbox.php b/app/SSH/Storage/Dropbox.php index 164541b..d560b95 100644 --- a/app/SSH/Storage/Dropbox.php +++ b/app/SSH/Storage/Dropbox.php @@ -44,4 +44,12 @@ public function download(string $src, string $dest): void 'download-from-dropbox' ); } + + /** + * @TODO Implement delete method + */ + public function delete(string $path): void + { + // + } } diff --git a/app/SSH/Storage/FTP.php b/app/SSH/Storage/FTP.php index 245a055..de7d98e 100644 --- a/app/SSH/Storage/FTP.php +++ b/app/SSH/Storage/FTP.php @@ -45,4 +45,12 @@ public function download(string $src, string $dest): void 'download-from-ftp' ); } + + /** + * @TODO Implement delete method + */ + public function delete(string $path): void + { + // + } } diff --git a/app/SSH/Storage/Local.php b/app/SSH/Storage/Local.php new file mode 100644 index 0000000..af065c5 --- /dev/null +++ b/app/SSH/Storage/Local.php @@ -0,0 +1,49 @@ +storageProvider->credentials['path'].$dest); + $destFile = basename($this->storageProvider->credentials['path'].$dest); + $this->server->ssh()->exec( + $this->getScript('local/upload.sh', [ + 'src' => $src, + 'dest_dir' => $destDir, + 'dest_file' => $destFile, + ]), + 'upload-to-local' + ); + + return [ + 'size' => null, + ]; + } + + public function download(string $src, string $dest): void + { + $this->server->ssh()->exec( + $this->getScript('local/download.sh', [ + 'src' => $this->storageProvider->credentials['path'].$src, + 'dest' => $dest, + ]), + 'download-from-local' + ); + } + + public function delete(string $path): void + { + $this->server->ssh()->exec( + $this->getScript('local/delete.sh', [ + 'path' => $this->storageProvider->credentials['path'].$path, + ]), + 'delete-from-local' + ); + } +} diff --git a/app/SSH/Storage/Storage.php b/app/SSH/Storage/Storage.php index cd54709..42c7dee 100644 --- a/app/SSH/Storage/Storage.php +++ b/app/SSH/Storage/Storage.php @@ -7,4 +7,6 @@ interface Storage public function upload(string $src, string $dest): array; public function download(string $src, string $dest): void; + + public function delete(string $path): void; } diff --git a/app/SSH/Storage/scripts/local/delete.sh b/app/SSH/Storage/scripts/local/delete.sh new file mode 100644 index 0000000..0946469 --- /dev/null +++ b/app/SSH/Storage/scripts/local/delete.sh @@ -0,0 +1 @@ +rm __path__ diff --git a/app/SSH/Storage/scripts/local/download.sh b/app/SSH/Storage/scripts/local/download.sh new file mode 100644 index 0000000..e3b5b34 --- /dev/null +++ b/app/SSH/Storage/scripts/local/download.sh @@ -0,0 +1 @@ +cp __src__ __dest__ diff --git a/app/SSH/Storage/scripts/local/upload.sh b/app/SSH/Storage/scripts/local/upload.sh new file mode 100644 index 0000000..a5c6f61 --- /dev/null +++ b/app/SSH/Storage/scripts/local/upload.sh @@ -0,0 +1,2 @@ +mkdir -p __dest_dir__ +cp __src__ __dest_dir__/__dest_file__ diff --git a/app/StorageProviders/Local.php b/app/StorageProviders/Local.php new file mode 100644 index 0000000..2221744 --- /dev/null +++ b/app/StorageProviders/Local.php @@ -0,0 +1,38 @@ + 'required', + ]; + } + + public function credentialData(array $input): array + { + return [ + 'path' => $input['path'], + ]; + } + + public function connect(): bool + { + return true; + } + + public function ssh(Server $server): Storage + { + return new \App\SSH\Storage\Local($server, $this->storageProvider); + } + + public function delete(array $paths): void + { + // + } +} diff --git a/config/core.php b/config/core.php index a5ab2ef..bfb79c6 100755 --- a/config/core.php +++ b/config/core.php @@ -359,10 +359,12 @@ 'storage_providers' => [ \App\Enums\StorageProvider::DROPBOX, \App\Enums\StorageProvider::FTP, + \App\Enums\StorageProvider::LOCAL, ], 'storage_providers_class' => [ - 'dropbox' => \App\StorageProviders\Dropbox::class, - 'ftp' => \App\StorageProviders\Ftp::class, + \App\Enums\StorageProvider::DROPBOX => \App\StorageProviders\Dropbox::class, + \App\Enums\StorageProvider::FTP => \App\StorageProviders\Ftp::class, + \App\Enums\StorageProvider::LOCAL => \App\StorageProviders\Local::class, ], 'ssl_types' => [ diff --git a/public/static/images/custom.svg b/public/static/images/custom.svg index cf5ab3a..54cf557 100644 --- a/public/static/images/custom.svg +++ b/public/static/images/custom.svg @@ -1,74 +1,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + \ No newline at end of file diff --git a/public/static/images/email.svg b/public/static/images/email.svg index 8d70dfb..c798a8d 100644 --- a/public/static/images/email.svg +++ b/public/static/images/email.svg @@ -1 +1,5 @@ - + + + \ No newline at end of file diff --git a/public/static/images/error.svg b/public/static/images/error.svg deleted file mode 100755 index e5a22ec..0000000 --- a/public/static/images/error.svg +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/public/static/images/ftp.svg b/public/static/images/ftp.svg new file mode 100644 index 0000000..8cf6a57 --- /dev/null +++ b/public/static/images/ftp.svg @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/public/static/images/local.svg b/public/static/images/local.svg new file mode 100644 index 0000000..4cabe54 --- /dev/null +++ b/public/static/images/local.svg @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/public/static/images/monitoring.svg b/public/static/images/monitoring.svg index 88803ce..eb6296a 100644 --- a/public/static/images/monitoring.svg +++ b/public/static/images/monitoring.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/public/static/images/openvpn.svg b/public/static/images/openvpn.svg deleted file mode 100644 index 7203f28..0000000 --- a/public/static/images/openvpn.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/static/images/remote-monitor.svg b/public/static/images/remote-monitor.svg index 0e7d376..99aad59 100644 --- a/public/static/images/remote-monitor.svg +++ b/public/static/images/remote-monitor.svg @@ -1,29 +1,5 @@ - - - - - - - Miscellaneous - - - health-monitoring - - - Health Monitoring - - - image/svg+xml - - - Amido Limited - - - Richard Slater - - - - - - + + \ No newline at end of file diff --git a/public/static/images/server.svg b/public/static/images/server.svg index cf5ab3a..54cf557 100755 --- a/public/static/images/server.svg +++ b/public/static/images/server.svg @@ -1,74 +1,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + \ No newline at end of file diff --git a/public/static/images/supervisor.svg b/public/static/images/supervisor.svg index 3203fe5..d234ba0 100644 --- a/public/static/images/supervisor.svg +++ b/public/static/images/supervisor.svg @@ -1,9 +1,5 @@ - - - - - - - + + \ No newline at end of file diff --git a/public/static/images/ufw.svg b/public/static/images/ufw.svg index 2843aa3..de0685f 100644 --- a/public/static/images/ufw.svg +++ b/public/static/images/ufw.svg @@ -1,9 +1,7 @@ - - -

@@ -31,7 +47,7 @@ class="p-6" @foreach (config("core.storage_providers") as $p) @if ($p !== "custom") -