2026-05-19 04:48:13 +02:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from django.contrib import admin
|
|
|
|
|
|
|
|
|
|
from .models import BackupRun, GlobalConfig, HostConfig, ScheduleConfig, SnapshotRecord
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(GlobalConfig)
|
|
|
|
|
class GlobalConfigAdmin(admin.ModelAdmin):
|
2026-05-19 05:04:49 +02:00
|
|
|
list_display = ("name", "backup_root", "ssh_user", "ssh_port", "updated_at")
|
2026-05-19 04:48:13 +02:00
|
|
|
readonly_fields = ("created_at", "updated_at")
|
2026-05-19 05:04:49 +02:00
|
|
|
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",)}),
|
|
|
|
|
)
|
2026-05-19 04:48:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(HostConfig)
|
|
|
|
|
class HostConfigAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ("host", "address", "enabled", "updated_at")
|
|
|
|
|
list_filter = ("enabled",)
|
|
|
|
|
search_fields = ("host", "address")
|
|
|
|
|
readonly_fields = ("created_at", "updated_at")
|
2026-05-19 05:04:49 +02:00
|
|
|
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",)}),
|
|
|
|
|
)
|
2026-05-19 04:48:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(BackupRun)
|
|
|
|
|
class BackupRunAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ("host", "run_type", "status", "started_at", "ended_at", "snapshot_path")
|
|
|
|
|
list_filter = ("run_type", "status", "started_at")
|
|
|
|
|
search_fields = ("host__host", "snapshot_path")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(SnapshotRecord)
|
|
|
|
|
class SnapshotRecordAdmin(admin.ModelAdmin):
|
2026-05-19 05:18:01 +02:00
|
|
|
list_display = ("host", "kind", "dirname", "status", "started_at", "discovered_at")
|
|
|
|
|
list_filter = ("kind", "status", "started_at", "discovered_at")
|
2026-05-19 04:48:13 +02:00
|
|
|
search_fields = ("host__host", "dirname", "path")
|
2026-05-19 05:18:01 +02:00
|
|
|
readonly_fields = ("discovered_at",)
|
2026-05-19 04:48:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(ScheduleConfig)
|
|
|
|
|
class ScheduleConfigAdmin(admin.ModelAdmin):
|
2026-05-19 04:57:10 +02:00
|
|
|
list_display = ("host", "cron_expr", "enabled", "prune", "last_status", "last_started_at", "updated_at")
|
|
|
|
|
list_filter = ("enabled", "prune", "last_status")
|
2026-05-19 04:48:13 +02:00
|
|
|
search_fields = ("host__host", "cron_expr")
|