diff --git a/docs/deployment.md b/docs/deployment.md index e28b587..9dfd1e5 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -1781,7 +1781,13 @@ sudo restic --repository-file "$profile/repository" \ sudo /opt/coulobre/bin/coulobre-account-backup verify-offsite vault ``` -Set `COULOBRE_OFFSITE_BACKUP_DESTINATIONS='{"vault":"Off-site vault"}'` in +On an installer-managed panel, open **Server Manager → Operator Settings → +Backups** and choose **Configure** for off-site backup destinations. Enter +the destination ID, such as `vault`. Coulobre verifies the existing +repository and enables the transfer worker for the first destination. + +For manual installations or additional destinations, set +`COULOBRE_OFFSITE_BACKUP_DESTINATIONS='{"vault":"Off-site vault"}'` in `/etc/coulobre/panel.env`. This setting contains IDs and labels. Each ID maps to a directory under `/etc/coulobre/offsite` on the backup node. diff --git a/src/coulobre/hosting/installation_views.py b/src/coulobre/hosting/installation_views.py index c765752..8ec801b 100644 --- a/src/coulobre/hosting/installation_views.py +++ b/src/coulobre/hosting/installation_views.py @@ -42,6 +42,11 @@ TOOL_FEATURES = { "LOCAL_DATABASE_PROVISIONING", ), "roundcube": ("email", "ROUNDCUBE_URL", "MAILBOX_PASSWORD_CHANGES"), + "offsite": ( + "backups", + "OFFSITE_BACKUP_DESTINATIONS", + "LOCAL_ACCOUNT_BACKUPS", + ), } TOOL_SETTINGS = { setting: tool for tool, (_, setting, _) in TOOL_FEATURES.items() @@ -302,7 +307,9 @@ class FeatureConfigurationView(UserPassesTestMixin, FormView): PanelFeaturePolicy.objects.get_or_create(pk=1) PanelFeaturePolicy.objects.select_for_update().get(pk=1) previous = ( - OperatorOperation.objects.filter(action="feature-enable") + OperatorOperation.objects.filter( + action__in=("feature-enable", TOOL_SETUP_ACTION) + ) .order_by("-pk") .first() ) @@ -371,23 +378,29 @@ class FeatureConfigurationView(UserPassesTestMixin, FormView): class ManagedToolForm(forms.Form): - hostname = forms.CharField(max_length=253, label="HTTPS hostname") + endpoint = forms.CharField(max_length=253, label="HTTPS hostname") def __init__(self, *args, tool, **kwargs): super().__init__(*args, **kwargs) self.tool = tool + if tool == "offsite": + self.fields["endpoint"] = forms.CharField( + max_length=48, label="Destination ID" + ) - def clean_hostname(self): + def clean_endpoint(self): try: - spec = ToolSetupRequest(self.tool, self.cleaned_data["hostname"]) + spec = ToolSetupRequest(self.tool, self.cleaned_data["endpoint"]) except ValueError as error: raise forms.ValidationError(str(error)) from error + if self.tool == "offsite": + return spec.endpoint if ( - f"https://{spec.hostname}" == settings.PASSWORD_RESET_ORIGIN - or WebsiteDomain.objects.filter(domain=spec.hostname).exists() + f"https://{spec.endpoint}" == settings.PASSWORD_RESET_ORIGIN + or WebsiteDomain.objects.filter(domain=spec.endpoint).exists() ): raise forms.ValidationError("Use a separate, unused hostname.") - return spec.hostname + return spec.endpoint @method_decorator(never_cache, name="dispatch") @@ -420,6 +433,7 @@ class ManagedToolSetupView(UserPassesTestMixin, FormView): ) return super().get_context_data( tool_label=HOSTING_TOOLS[self.tool], + tool=self.tool, section=TOOL_FEATURES[self.tool][0], available=managed_tool_available(self.tool), pending=package_operation_pending(job), @@ -451,12 +465,12 @@ class ManagedToolSetupView(UserPassesTestMixin, FormView): None, "Wait for the current feature setup to finish." ) return self.form_invalid(form) - spec = ToolSetupRequest(self.tool, form.cleaned_data["hostname"]) + spec = ToolSetupRequest(self.tool, form.cleaned_data["endpoint"]) queue_operator_request( self.request.user, spec, retryable=True, - parameters={"hostname": spec.hostname}, + parameters={"endpoint": spec.endpoint}, ) messages.success( self.request, f"{HOSTING_TOOLS[self.tool]} setup queued." diff --git a/src/coulobre/hosting/tasks.py b/src/coulobre/hosting/tasks.py index 8d6813a..e594312 100644 --- a/src/coulobre/hosting/tasks.py +++ b/src/coulobre/hosting/tasks.py @@ -1409,7 +1409,7 @@ def run_operator_operation(job_id): raise ValueError( "The requesting operator no longer has access." ) - spec = ToolSetupRequest(job.target, job.parameters.get("hostname")) + spec = ToolSetupRequest(job.target, job.parameters.get("endpoint")) elif job.action == "http-defaults": spec = HttpDefaultsRequest(job.target, job.parameters) else: diff --git a/src/coulobre/hosting/templates/hosting/managed_tool_setup.html b/src/coulobre/hosting/templates/hosting/managed_tool_setup.html index 60e8ec5..518276a 100644 --- a/src/coulobre/hosting/templates/hosting/managed_tool_setup.html +++ b/src/coulobre/hosting/templates/hosting/managed_tool_setup.html @@ -21,7 +21,11 @@ {% endif %} {% if available %}
Point a dedicated hostname at this server. Coulobre uses an existing TLS certificate for the hostname or requests one through Let's Encrypt. Keep inbound HTTP available for certificate validation.
+ {% if tool == "offsite" %} +Enter the ID of an initialized restic repository with an SFTP profile in /etc/coulobre/offsite. Coulobre checks access before making it available for scheduled backups.
Point a dedicated hostname at this server. Coulobre uses an existing TLS certificate for the hostname or requests one through Let's Encrypt. Keep inbound HTTP available for certificate validation.
+ {% endif %}