Skip to content

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.

fix(backups): preserve existing volume backup timeouts

Andras Bacsaia3e968d03e38
diff --git a/app/Http/Controllers/Api/VolumeBackupsController.php b/app/Http/Controllers/Api/VolumeBackupsController.php
index a5225f5dd7..26ff938a10 100644
--- a/app/Http/Controllers/Api/VolumeBackupsController.php
+++ b/app/Http/Controllers/Api/VolumeBackupsController.php
@@ -261,7 +261,7 @@ class VolumeBackupsController extends Controller
string $resourceType,
Model $resource,
): JsonResponse {
- $backup = $storage->scheduledBackups()->updateOrCreate([], [
+ $attributes = [
'team_id' => $teamId,
'frequency' => $request->string('frequency')->toString(),
'enabled' => $request->boolean('enabled', true),
@@ -275,8 +275,12 @@ class VolumeBackupsController extends Controller
'retention_amount_s3' => $request->integer('retention_amount_s3', 7),
'retention_days_s3' => $request->integer('retention_days_s3'),
'retention_max_storage_s3' => $request->float('retention_max_storage_s3'),
- 'timeout' => $request->integer('timeout', ScheduledVolumeBackup::DEFAULT_TIMEOUT),
- ]);
+ ];
+ if ($request->has('timeout')) {
+ $attributes['timeout'] = $request->integer('timeout');
+ }
+
+ $backup = $storage->scheduledBackups()->updateOrCreate([], $attributes);
$created = $backup->wasRecentlyCreated;
auditLog('api.volume_backup.schedule_set', [
diff --git a/tests/Feature/Api/VolumeBackupScheduleApiTest.php b/tests/Feature/Api/VolumeBackupScheduleApiTest.php
index 4f4bc395bf..e60f2919da 100644
--- a/tests/Feature/Api/VolumeBackupScheduleApiTest.php
+++ b/tests/Feature/Api/VolumeBackupScheduleApiTest.php
@@ -130,6 +130,7 @@ it('updates the existing backup schedule instead of creating another one', funct
'save_s3' => true,
'disable_local_backup' => true,
's3_storage_id' => $this->s3Storage->id,
+ 'timeout' => 7200,
]);
$response = $this->withHeaders($this->headers)
@@ -146,7 +147,8 @@ it('updates the existing backup schedule instead of creating another one', funct
->and($backup->enabled)->toBeFalse()
->and($backup->save_s3)->toBeFalse()
->and($backup->disable_local_backup)->toBeFalse()
- ->and($backup->s3_storage_id)->toBeNull();
+ ->and($backup->s3_storage_id)->toBeNull()
+ ->and($backup->timeout)->toBe(7200);
});
it('sets a directory backup schedule through the API', function () {