From 14aabb8da796329de73ed8a0909e58c59cd46767 Mon Sep 17 00:00:00 2001 From: Peter van Arkel Date: Sat, 21 Nov 2026 14:42:38 +0100 Subject: [PATCH] Deploy the quota-aware local website restore socket --- deploy/panel.env.example | 1 + .../systemd/coulobre-account-restore.socket | 11 +++++ .../systemd/coulobre-account-restore@.service | 22 ++++++++++ .../restore.conf | 6 +++ docs/deployment.md | 42 +++++++++++++++++++ docs/development.md | 4 ++ 6 files changed, 86 insertions(+) create mode 100644 deploy/systemd/coulobre-account-restore.socket create mode 100644 deploy/systemd/coulobre-account-restore@.service create mode 100644 deploy/systemd/coulobre-backup-worker.service.d/restore.conf diff --git a/deploy/panel.env.example b/deploy/panel.env.example index febafb9..b9a1df7 100644 --- a/deploy/panel.env.example +++ b/deploy/panel.env.example @@ -16,3 +16,4 @@ COULOBRE_BROKER_URL=amqp://coulobre:@127.0.0.1:5672/coulobre # COULOBRE_LOCAL_MAILBOX_PROVISIONING=1 # COULOBRE_LOCAL_ACCOUNT_BACKUPS=1 # COULOBRE_LOCAL_ACCOUNT_BACKUP_MAIL=1 +# COULOBRE_LOCAL_WEBSITE_RESTORE=1 diff --git a/deploy/systemd/coulobre-account-restore.socket b/deploy/systemd/coulobre-account-restore.socket new file mode 100644 index 0000000..ffce980 --- /dev/null +++ b/deploy/systemd/coulobre-account-restore.socket @@ -0,0 +1,11 @@ +[Unit] +Description=Coulobre local website restore socket + +[Socket] +ListenStream=/run/coulobre-account-restore.sock +SocketUser=root +SocketGroup=coulobre-restore-requests +SocketMode=0660 +Accept=yes +MaxConnections=4 +RemoveOnStop=true diff --git a/deploy/systemd/coulobre-account-restore@.service b/deploy/systemd/coulobre-account-restore@.service new file mode 100644 index 0000000..d75e1b3 --- /dev/null +++ b/deploy/systemd/coulobre-account-restore@.service @@ -0,0 +1,22 @@ +[Unit] +Description=Coulobre local website restore request +CollectMode=inactive-or-failed + +[Service] +Type=exec +User=root +WorkingDirectory=/opt/coulobre +StateDirectory=coulobre/account-restores +StateDirectoryMode=0700 +ReadWritePaths=-/srv/coulobre/web +UMask=0077 +ExecStart=/opt/coulobre/bin/coulobre-account-backup restore-website-request +StandardInput=socket +StandardOutput=socket +StandardError=journal +RuntimeMaxSec=30min +NoNewPrivileges=true +CapabilityBoundingSet=~CAP_SYS_RESOURCE +PrivateTmp=true +ProtectHome=true +ProtectSystem=strict diff --git a/deploy/systemd/coulobre-backup-worker.service.d/restore.conf b/deploy/systemd/coulobre-backup-worker.service.d/restore.conf new file mode 100644 index 0000000..9d722f2 --- /dev/null +++ b/deploy/systemd/coulobre-backup-worker.service.d/restore.conf @@ -0,0 +1,6 @@ +[Unit] +Requires=coulobre-account-restore.socket +After=coulobre-account-restore.socket + +[Service] +SupplementaryGroups=coulobre-restore-requests diff --git a/docs/deployment.md b/docs/deployment.md index 56cabdd..cc8389d 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -420,6 +420,48 @@ most one missed backup per account and continues with the next future time. Scheduled ZIPs are stored alongside manual backups and require the same server-side retention management. +#### Restore website files from the panel + +Enable this feature when the website and account backup archive are on the +same server. Install the restore socket and give the backup worker access to +it. + +```sh +sudo groupadd --system coulobre-restore-requests +sudo install -m 0644 deploy/systemd/coulobre-account-restore.socket \ + deploy/systemd/coulobre-account-restore@.service /etc/systemd/system/ +sudo install -D -m 0644 deploy/systemd/coulobre-backup-worker.service.d/restore.conf \ + /etc/systemd/system/coulobre-backup-worker.service.d/restore.conf +sudo systemctl daemon-reload +``` + +Set `COULOBRE_LOCAL_WEBSITE_RESTORE=1` in `/etc/coulobre/panel.env`. + +```sh +panel_manage migrate --noinput +sudo systemctl restart coulobre-panel coulobre-worker coulobre-backup-worker +``` + +Select **Restore website** on a completed backup for the current account and +domain. Operators need the backup permissions listed above and **Can add +website restore job**. A backup that includes mail also requires permission +to view mailbox requests. + +For one file, enter its path relative to the document root. Make sure the +parent directory exists. Select **Replace the existing file at this path** +only if an existing site-owned file should be overwritten. Choose **Entire +website** to restore all website files to an empty document root. When +replacing a file, its old and restored copies must fit within the website's +storage quota during staging. The **Website restores** section records the +source backup, operator, and result. + +Restore request records under `/var/lib/coulobre/account-restores/` prevent +an interrupted worker from applying the same restore twice. Keep these +records while corresponding jobs could still be delivered. If the panel +cannot confirm a restore, check the destination before submitting another. +Use the [account bundle commands](development.md#recover-backups-from-the-bundle) +to recover databases, mail, or components on separate servers. + #### Include mailboxes on the same server Complete the [Postfix and Dovecot setup](development.md#apply-a-mailbox-manifest) diff --git a/docs/development.md b/docs/development.md index 9723eed..fe4cbc2 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1073,6 +1073,10 @@ sudo /opt/coulobre/bin/coulobre-account-backup pack \ ### Recover backups from the bundle +On a single-server installation, operators can restore one file or the entire +website from a completed account backup. See +[restoring from the panel](deployment.md#restore-website-files-from-the-panel). + Unpack to a new directory on a root-controlled path. The command verifies the ZIP contents and checks the identity and integrity of each compressed component before publishing the directory.