(bugfix) preserve saved global backup root in Django setup form
Fix the global config edit view so default initial values are only used when creating a new config, preventing saved backup_root values from being hidden by form defaults. Keep pobsync_home as an internal runtime setting instead of exposing it in the normal Django setup form. Mount a host backup directory into Docker at /backups and document POBSYNC_BACKUP_ROOT so backup_root behaves predictably in containers.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
|
||||
from .models import GlobalConfig, HostConfig, ScheduleConfig
|
||||
from .scheduler import parse_cron_expr
|
||||
@@ -84,7 +85,6 @@ class GlobalConfigForm(forms.ModelForm):
|
||||
fields = (
|
||||
"name",
|
||||
"backup_root",
|
||||
"pobsync_home",
|
||||
"ssh_user",
|
||||
"ssh_port",
|
||||
"ssh_options",
|
||||
@@ -104,11 +104,18 @@ class GlobalConfigForm(forms.ModelForm):
|
||||
help_texts = {
|
||||
"name": "Usually 'default'. The backup engine currently reads the default config.",
|
||||
"backup_root": "Directory that contains host backup folders.",
|
||||
"pobsync_home": "Base directory for runtime state inside the container or host.",
|
||||
"default_source_root": "Used by hosts without a custom source root.",
|
||||
"default_destination_subdir": "Optional subdirectory below each snapshot.",
|
||||
}
|
||||
|
||||
def save(self, commit: bool = True):
|
||||
instance = super().save(commit=False)
|
||||
instance.pobsync_home = settings.POBSYNC_HOME
|
||||
if commit:
|
||||
instance.save()
|
||||
self.save_m2m()
|
||||
return instance
|
||||
|
||||
|
||||
class ScheduleConfigForm(forms.ModelForm):
|
||||
cron_expr = forms.CharField(
|
||||
|
||||
Reference in New Issue
Block a user