fix(backups): retain volume backups without server
This commit is contained in:
parent
b97a97e955
commit
994eee8377
2 changed files with 41 additions and 2 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Actions\Shared\DeleteScheduledVolumeBackup;
|
||||
use App\Models\ScheduledDatabaseBackup;
|
||||
use App\Models\ScheduledTask;
|
||||
use App\Models\ScheduledVolumeBackup;
|
||||
|
|
@ -397,8 +398,8 @@ private function processScheduledVolumeBackup(ScheduledVolumeBackup $backup): vo
|
|||
return;
|
||||
}
|
||||
|
||||
if (! $backup->backupable || ! $server) {
|
||||
$backup->delete();
|
||||
if (! $backup->backupable) {
|
||||
DeleteScheduledVolumeBackup::run($backup, $server);
|
||||
$this->skippedCount++;
|
||||
$this->logSkip('volume_backup', 'resource_deleted', [
|
||||
'backup_id' => $backup->id,
|
||||
|
|
@ -408,6 +409,16 @@ private function processScheduledVolumeBackup(ScheduledVolumeBackup $backup): vo
|
|||
return;
|
||||
}
|
||||
|
||||
if (! $server) {
|
||||
$this->skippedCount++;
|
||||
$this->logSkip('volume_backup', 'server_missing', [
|
||||
'backup_id' => $backup->id,
|
||||
'team_id' => $backup->team_id,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $server->isFunctional()) {
|
||||
$this->skippedCount++;
|
||||
$this->logSkip('volume_backup', 'server_not_functional', [
|
||||
|
|
|
|||
|
|
@ -2010,6 +2010,34 @@ function signInForVolumeBackups($testCase, Team $team): User
|
|||
);
|
||||
});
|
||||
|
||||
it('retains scheduled volume backups and archive metadata when the server is missing', function () {
|
||||
config(['constants.coolify.self_hosted' => true]);
|
||||
Queue::fake();
|
||||
$team = Team::factory()->create();
|
||||
[$application, $volume] = createVolumeBackupApplication($team);
|
||||
$backup = $volume->scheduledBackups()->create([
|
||||
'team_id' => $team->id,
|
||||
'frequency' => '* * * * *',
|
||||
'enabled' => true,
|
||||
]);
|
||||
$execution = ScheduledVolumeBackupExecution::create([
|
||||
'scheduled_volume_backup_id' => $backup->id,
|
||||
'status' => 'success',
|
||||
'filename' => '/data/coolify/backups/volumes/test/archive.tar.gz',
|
||||
]);
|
||||
$application->update([
|
||||
'destination_id' => null,
|
||||
'destination_type' => null,
|
||||
]);
|
||||
|
||||
(new ScheduledJobManager)->handle();
|
||||
|
||||
expect($backup->fresh())->not->toBeNull()
|
||||
->and($execution->fresh())->not->toBeNull()
|
||||
->and($execution->fresh()->filename)->toBe('/data/coolify/backups/volumes/test/archive.tar.gz');
|
||||
Queue::assertNotPushed(VolumeBackupJob::class);
|
||||
});
|
||||
|
||||
it('dispatches pending recovery without starting another volume backup', function () {
|
||||
config(['constants.coolify.self_hosted' => true]);
|
||||
Queue::fake();
|
||||
|
|
|
|||
Loading…
Reference in a new issue