(refactor) make Docker backup root static in Django setup

Remove backup_root from the normal Django global config form and display
the fixed container path /backups instead.

Always persist /backups from the setup form so Docker deployments do not
mix host paths with container paths.

Update tests and docs to clarify that the host backup directory is chosen
through the Docker mount, while Django always uses /backups internally.
This commit is contained in:
2026-05-19 13:14:22 +02:00
parent 3da877eb8a
commit 573177e118
7 changed files with 53 additions and 10 deletions

View File

@@ -75,7 +75,6 @@ class ViewTests(TestCase):
reverse("edit_global_config"),
{
"name": "default",
"backup_root": "/backups",
"ssh_user": "backup",
"ssh_port": "2222",
"ssh_options": "StrictHostKeyChecking=no\nBatchMode=yes",
@@ -109,7 +108,7 @@ class ViewTests(TestCase):
self.assertEqual(config.retention_daily, 7)
self.assertEqual(config.retention_yearly, 1)
def test_global_config_form_renders_saved_backup_root_on_edit(self) -> None:
def test_global_config_form_renders_static_container_backup_root_on_edit(self) -> None:
self.client.force_login(self.staff_user)
GlobalConfig.objects.create(
name="default",
@@ -120,10 +119,48 @@ class ViewTests(TestCase):
response = self.client.get(reverse("edit_global_config"))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "/mnt/pobsync/backups")
self.assertContains(response, "Backup root:")
self.assertContains(response, "/backups")
self.assertNotContains(response, "/mnt/pobsync/backups")
self.assertNotContains(response, "/opt/pobsync/backups")
self.assertNotContains(response, "Pobsync home")
def test_global_config_form_resets_backup_root_to_static_container_path(self) -> None:
self.client.force_login(self.staff_user)
GlobalConfig.objects.create(
name="default",
backup_root="/mnt/pobsync/backups",
pobsync_home="/custom/legacy/home",
)
response = self.client.post(
reverse("edit_global_config"),
{
"name": "default",
"ssh_user": "root",
"ssh_port": "22",
"ssh_options": "",
"rsync_binary": "rsync",
"rsync_args": "",
"rsync_extra_args": "",
"rsync_timeout_seconds": "0",
"rsync_bwlimit_kbps": "0",
"default_source_root": "/",
"default_destination_subdir": "",
"excludes_default": "",
"retention_daily": "14",
"retention_weekly": "8",
"retention_monthly": "12",
"retention_yearly": "0",
},
follow=True,
)
self.assertRedirects(response, reverse("dashboard"))
config = GlobalConfig.objects.get(name="default")
self.assertEqual(config.backup_root, "/backups")
self.assertEqual(config.pobsync_home, "/opt/pobsync")
def test_create_host_config_form_creates_host(self) -> None:
self.client.force_login(self.staff_user)