refactor: promote backup configuration to structured SQL fields
Add explicit Django model fields for global and host backup settings, including SSH, rsync, source, excludes, and retention configuration. Populate them from legacy JSON during migration, make the config repository prefer structured fields, and update import/admin/tests around the SQL-first configuration model.
This commit is contained in:
@@ -7,8 +7,28 @@ from .models import BackupRun, GlobalConfig, HostConfig, ScheduleConfig, Snapsho
|
||||
|
||||
@admin.register(GlobalConfig)
|
||||
class GlobalConfigAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "backup_root", "updated_at")
|
||||
list_display = ("name", "backup_root", "ssh_user", "ssh_port", "updated_at")
|
||||
readonly_fields = ("created_at", "updated_at")
|
||||
fieldsets = (
|
||||
(None, {"fields": ("name", "backup_root", "pobsync_home")}),
|
||||
("SSH", {"fields": ("ssh_user", "ssh_port", "ssh_options")}),
|
||||
(
|
||||
"Rsync",
|
||||
{
|
||||
"fields": (
|
||||
"rsync_binary",
|
||||
"rsync_args",
|
||||
"rsync_extra_args",
|
||||
"rsync_timeout_seconds",
|
||||
"rsync_bwlimit_kbps",
|
||||
)
|
||||
},
|
||||
),
|
||||
("Defaults", {"fields": ("default_source_root", "default_destination_subdir", "excludes_default")}),
|
||||
("Retention defaults", {"fields": ("retention_daily", "retention_weekly", "retention_monthly", "retention_yearly")}),
|
||||
("Legacy JSON", {"fields": ("data",), "classes": ("collapse",)}),
|
||||
("Timestamps", {"fields": ("created_at", "updated_at"), "classes": ("collapse",)}),
|
||||
)
|
||||
|
||||
|
||||
@admin.register(HostConfig)
|
||||
@@ -17,6 +37,15 @@ class HostConfigAdmin(admin.ModelAdmin):
|
||||
list_filter = ("enabled",)
|
||||
search_fields = ("host", "address")
|
||||
readonly_fields = ("created_at", "updated_at")
|
||||
fieldsets = (
|
||||
(None, {"fields": ("host", "address", "enabled")}),
|
||||
("SSH override", {"fields": ("ssh_user", "ssh_port")}),
|
||||
("Source", {"fields": ("source_root", "includes", "excludes_add", "excludes_replace")}),
|
||||
("Rsync override", {"fields": ("rsync_extra_args",)}),
|
||||
("Retention", {"fields": ("retention_daily", "retention_weekly", "retention_monthly", "retention_yearly")}),
|
||||
("Legacy JSON", {"fields": ("config",), "classes": ("collapse",)}),
|
||||
("Timestamps", {"fields": ("created_at", "updated_at"), "classes": ("collapse",)}),
|
||||
)
|
||||
|
||||
|
||||
@admin.register(BackupRun)
|
||||
|
||||
Reference in New Issue
Block a user