feat(backups): add scheduled persistent volume backups

This commit is contained in:
Andras Bacsai committed 2026-07-15 15:47:57 +02:00
1 parent 05dc2c65f6
commit 63961e0799
36 files changed
+3506 -31

No files matched your search

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('scheduled_volume_backups', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->foreignId('local_persistent_volume_id')->unique()->constrained()->restrictOnDelete();
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
$table->foreignId('s3_storage_id')->nullable()->constrained()->nullOnDelete();
$table->string('frequency');
$table->boolean('enabled')->default(true);
$table->boolean('save_s3')->default(false);
$table->boolean('disable_local_backup')->default(false);
$table->boolean('pause_during_backup')->default(false);
$table->unsignedInteger('retention_amount_locally')->default(7);
$table->unsignedInteger('retention_amount_s3')->default(7);
$table->unsignedInteger('timeout')->default(3600);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('scheduled_volume_backups');
}
};
@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('scheduled_volume_backup_executions', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->foreignId('scheduled_volume_backup_id')->constrained()->cascadeOnDelete();
$table->enum('status', ['success', 'failed', 'running'])->default('running');
$table->longText('message')->nullable();
$table->unsignedBigInteger('size')->default(0);
$table->text('filename')->nullable();
$table->json('pause_container_ids')->nullable();
$table->boolean('pause_recovery_pending')->default(false);
$table->boolean('s3_cleanup_pending')->default(false);
$table->timestamp('finished_at')->nullable();
$table->boolean('local_storage_deleted')->default(false);
$table->boolean('s3_storage_deleted')->default(false);
$table->boolean('s3_uploaded')->nullable();
$table->timestamps();
$table->index(['scheduled_volume_backup_id', 'created_at'], 'scheduled_volume_executions_backup_created_index');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('scheduled_volume_backup_executions');
}
};
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('scheduled_volume_backups', function (Blueprint $table) {
$table->unsignedInteger('retention_days_locally')->default(0);
$table->decimal('retention_max_storage_locally', 17, 7)->default(0);
$table->unsignedInteger('retention_days_s3')->default(0);
$table->decimal('retention_max_storage_s3', 17, 7)->default(0);
});
}
public function down(): void
{
Schema::table('scheduled_volume_backups', function (Blueprint $table) {
$table->dropColumn([
'retention_days_locally',
'retention_max_storage_locally',
'retention_days_s3',
'retention_max_storage_s3',
]);
});
}
};