mirror of
https://github.com/pelican-dev/panel.git
synced 2026-05-04 18:00:48 +03:00
delete all (remote) backups when server is deleted
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Services\Servers;
|
||||
|
||||
use App\Exceptions\DisplayException;
|
||||
use App\Extensions\BackupAdapter\BackupAdapterService;
|
||||
use App\Extensions\BackupAdapter\Schemas\WingsBackupSchema;
|
||||
use App\Models\Server;
|
||||
use App\Repositories\Daemon\DaemonServerRepository;
|
||||
use App\Services\Databases\DatabaseManagementService;
|
||||
@@ -22,7 +24,8 @@ class ServerDeletionService
|
||||
public function __construct(
|
||||
private ConnectionInterface $connection,
|
||||
private DaemonServerRepository $daemonServerRepository,
|
||||
private DatabaseManagementService $databaseManagementService
|
||||
private DatabaseManagementService $databaseManagementService,
|
||||
private BackupAdapterService $backupService
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -78,6 +81,26 @@ class ServerDeletionService
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($server->backups as $backup) {
|
||||
try {
|
||||
$schema = $this->backupService->get($backup->backupHost->schema);
|
||||
|
||||
if ($schema) {
|
||||
if ($schema instanceof WingsBackupSchema) {
|
||||
// Local wings backups are already deleted by the daemon
|
||||
} else {
|
||||
$schema->deleteBackup($backup);
|
||||
}
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
if (!$this->force) {
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
logger()->warning($exception);
|
||||
}
|
||||
}
|
||||
|
||||
$server->allocations()->update([
|
||||
'server_id' => null,
|
||||
'notes' => null,
|
||||
|
||||
Reference in New Issue
Block a user