feat(backups): support scheduled backups for application storage targets

Add polymorphic volume backup scheduling for persistent volumes and directories, expose schedule management via API, and reorganize backup configuration and execution views.
This commit is contained in:
Andras Bacsai
2026-07-15 17:34:22 +02:00
parent 995ec5fbb6
commit d7385ad0c4
60 changed files with 3570 additions and 985 deletions
+19 -1
View File
@@ -6,6 +6,8 @@ use App\Events\FileStorageChanged;
use App\Jobs\ServerStorageSaveJob;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Symfony\Component\Yaml\Yaml;
class LocalFileVolume extends BaseModel
@@ -57,6 +59,12 @@ class LocalFileVolume extends BaseModel
$fileVolume->load(['service']);
dispatch(new ServerStorageSaveJob($fileVolume));
});
static::deleting(function (LocalFileVolume $fileVolume): void {
if ($fileVolume->scheduledBackups()->exists()) {
throw new \RuntimeException('Delete this directory backup schedule and its archives before deleting the directory.');
}
});
}
protected function isBinary(): Attribute
@@ -73,11 +81,21 @@ class LocalFileVolume extends BaseModel
);
}
public function service()
public function resource(): MorphTo
{
return $this->morphTo();
}
public function service(): MorphTo
{
return $this->morphTo('resource');
}
public function scheduledBackups(): MorphMany
{
return $this->morphMany(ScheduledVolumeBackup::class, 'backupable');
}
public function loadStorageOnServer()
{
if ($this->is_host_file) {