feat: add Django backend foundation and Docker runtime
Add a Django admin-backed management layer for pobsync configs, runs, snapshots, and schedules. Keep the existing CLI engine as the execution source of truth, add import/run management commands, and provide SQLite default plus optional MariaDB Docker Compose support.
This commit is contained in:
103
src/pobsync_backend/migrations/0001_initial.py
Normal file
103
src/pobsync_backend/migrations/0001_initial.py
Normal file
@@ -0,0 +1,103 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = []
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="GlobalConfig",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("name", models.CharField(default="default", max_length=64, unique=True)),
|
||||
("backup_root", models.CharField(max_length=512)),
|
||||
("pobsync_home", models.CharField(default="/opt/pobsync", max_length=512)),
|
||||
("data", models.JSONField(blank=True, default=dict)),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "global config",
|
||||
"verbose_name_plural": "global configs",
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="HostConfig",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("host", models.CharField(max_length=255, unique=True)),
|
||||
("address", models.CharField(max_length=255)),
|
||||
("enabled", models.BooleanField(default=True)),
|
||||
("config", models.JSONField(blank=True, default=dict)),
|
||||
],
|
||||
options={
|
||||
"ordering": ["host"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="BackupRun",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("run_type", models.CharField(choices=[("scheduled", "Scheduled"), ("manual", "Manual")], default="scheduled", max_length=16)),
|
||||
("status", models.CharField(choices=[("queued", "Queued"), ("running", "Running"), ("success", "Success"), ("failed", "Failed"), ("cancelled", "Cancelled")], default="queued", max_length=16)),
|
||||
("started_at", models.DateTimeField(blank=True, null=True)),
|
||||
("ended_at", models.DateTimeField(blank=True, null=True)),
|
||||
("snapshot_path", models.CharField(blank=True, max_length=1024)),
|
||||
("base_path", models.CharField(blank=True, max_length=1024)),
|
||||
("rsync_exit_code", models.IntegerField(blank=True, null=True)),
|
||||
("result", models.JSONField(blank=True, default=dict)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("host", models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name="runs", to="pobsync_backend.hostconfig")),
|
||||
],
|
||||
options={
|
||||
"ordering": ["-created_at"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="ScheduleConfig",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("cron_expr", models.CharField(max_length=128)),
|
||||
("user", models.CharField(default="root", max_length=64)),
|
||||
("enabled", models.BooleanField(default=True)),
|
||||
("prune", models.BooleanField(default=False)),
|
||||
("prune_max_delete", models.PositiveIntegerField(default=10)),
|
||||
("prune_protect_bases", models.BooleanField(default=False)),
|
||||
("host", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name="schedule", to="pobsync_backend.hostconfig")),
|
||||
],
|
||||
options={
|
||||
"ordering": ["host__host"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="SnapshotRecord",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("kind", models.CharField(choices=[("scheduled", "Scheduled"), ("manual", "Manual"), ("incomplete", "Incomplete")], max_length=16)),
|
||||
("dirname", models.CharField(max_length=255)),
|
||||
("path", models.CharField(max_length=1024)),
|
||||
("status", models.CharField(blank=True, max_length=32)),
|
||||
("started_at", models.DateTimeField(blank=True, null=True)),
|
||||
("ended_at", models.DateTimeField(blank=True, null=True)),
|
||||
("metadata", models.JSONField(blank=True, default=dict)),
|
||||
("discovered_at", models.DateTimeField(auto_now_add=True)),
|
||||
("host", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="snapshots", to="pobsync_backend.hostconfig")),
|
||||
],
|
||||
options={
|
||||
"ordering": ["host__host", "-started_at", "dirname"],
|
||||
},
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="snapshotrecord",
|
||||
constraint=models.UniqueConstraint(fields=("host", "kind", "dirname"), name="unique_snapshot_per_host_kind"),
|
||||
),
|
||||
]
|
||||
1
src/pobsync_backend/migrations/__init__.py
Normal file
1
src/pobsync_backend/migrations/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user