From 92bd75c19610352540bc098b6c9d39adeb224275 Mon Sep 17 00:00:00 2001 From: Peter van Arkel Date: Sat, 21 Nov 2026 14:54:51 +0100 Subject: [PATCH] Document and deploy opt-in account backup recovery --- deploy/panel.env.example | 2 + .../systemd/coulobre-account-restore.socket | 2 +- .../systemd/coulobre-account-restore@.service | 5 +- .../database.conf | 6 ++ .../mailbox.conf | 6 ++ .../website.conf | 3 + docs/deployment.md | 75 +++++++++++++------ docs/development.md | 6 +- 8 files changed, 75 insertions(+), 30 deletions(-) create mode 100644 deploy/systemd/coulobre-account-restore@.service.d/database.conf create mode 100644 deploy/systemd/coulobre-account-restore@.service.d/mailbox.conf create mode 100644 deploy/systemd/coulobre-account-restore@.service.d/website.conf diff --git a/deploy/panel.env.example b/deploy/panel.env.example index b9a1df7..445f065 100644 --- a/deploy/panel.env.example +++ b/deploy/panel.env.example @@ -17,3 +17,5 @@ COULOBRE_BROKER_URL=amqp://coulobre:@127.0.0.1:5672/coulobre # COULOBRE_LOCAL_ACCOUNT_BACKUPS=1 # COULOBRE_LOCAL_ACCOUNT_BACKUP_MAIL=1 # COULOBRE_LOCAL_WEBSITE_RESTORE=1 +# COULOBRE_LOCAL_DATABASE_RESTORE=1 +# COULOBRE_LOCAL_MAILBOX_RESTORE=1 diff --git a/deploy/systemd/coulobre-account-restore.socket b/deploy/systemd/coulobre-account-restore.socket index ffce980..e9588b5 100644 --- a/deploy/systemd/coulobre-account-restore.socket +++ b/deploy/systemd/coulobre-account-restore.socket @@ -1,5 +1,5 @@ [Unit] -Description=Coulobre local website restore socket +Description=Coulobre local account restore socket [Socket] ListenStream=/run/coulobre-account-restore.sock diff --git a/deploy/systemd/coulobre-account-restore@.service b/deploy/systemd/coulobre-account-restore@.service index d75e1b3..008a4b7 100644 --- a/deploy/systemd/coulobre-account-restore@.service +++ b/deploy/systemd/coulobre-account-restore@.service @@ -1,5 +1,5 @@ [Unit] -Description=Coulobre local website restore request +Description=Coulobre local account restore request CollectMode=inactive-or-failed [Service] @@ -8,9 +8,8 @@ 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 +ExecStart=/opt/coulobre/bin/coulobre-account-backup restore-request StandardInput=socket StandardOutput=socket StandardError=journal diff --git a/deploy/systemd/coulobre-account-restore@.service.d/database.conf b/deploy/systemd/coulobre-account-restore@.service.d/database.conf new file mode 100644 index 0000000..0d67695 --- /dev/null +++ b/deploy/systemd/coulobre-account-restore@.service.d/database.conf @@ -0,0 +1,6 @@ +[Unit] +After=mariadb.service + +[Service] +Environment=COULOBRE_LOCAL_DATABASE_RESTORE=1 +ReadWritePaths=-/var/lib/coulobre/database-node diff --git a/deploy/systemd/coulobre-account-restore@.service.d/mailbox.conf b/deploy/systemd/coulobre-account-restore@.service.d/mailbox.conf new file mode 100644 index 0000000..e91f3c4 --- /dev/null +++ b/deploy/systemd/coulobre-account-restore@.service.d/mailbox.conf @@ -0,0 +1,6 @@ +[Unit] +After=postfix.service dovecot.service + +[Service] +Environment=COULOBRE_LOCAL_MAILBOX_RESTORE=1 +ReadWritePaths=-/srv/coulobre-mail diff --git a/deploy/systemd/coulobre-account-restore@.service.d/website.conf b/deploy/systemd/coulobre-account-restore@.service.d/website.conf new file mode 100644 index 0000000..bed2784 --- /dev/null +++ b/deploy/systemd/coulobre-account-restore@.service.d/website.conf @@ -0,0 +1,3 @@ +[Service] +Environment=COULOBRE_LOCAL_WEBSITE_RESTORE=1 +ReadWritePaths=-/srv/coulobre/web diff --git a/docs/deployment.md b/docs/deployment.md index cc8389d..9aff926 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -420,11 +420,11 @@ 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 +#### Restore from local account backups in 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. +Enable local account backups first. Install the restore socket and give the +backup worker access to it. The archive and the resources being restored +must be on the same server. ```sh sudo groupadd --system coulobre-restore-requests @@ -432,35 +432,64 @@ 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`. +Enable the options you need in `/etc/coulobre/panel.env`. + +| Setting | Additional restore permission | +| --- | --- | +| `COULOBRE_LOCAL_WEBSITE_RESTORE=1` | **Can add website restore job** | +| `COULOBRE_LOCAL_DATABASE_RESTORE=1` | **Can restore an account database** | +| `COULOBRE_LOCAL_MAILBOX_RESTORE=1` | **Can restore an account mailbox** | + +Install the socket service drop-in for each enabled action. If you replace +an existing website-only restore unit, install the website drop-in to keep +website recovery enabled. MariaDB recovery uses the local default MariaDB +socket. Mailbox recovery uses local Postfix and Dovecot. + +```sh +# Website restores +sudo install -D -m 0644 deploy/systemd/coulobre-account-restore@.service.d/website.conf \ + /etc/systemd/system/coulobre-account-restore@.service.d/website.conf +# Database restores +sudo install -D -m 0644 deploy/systemd/coulobre-account-restore@.service.d/database.conf \ + /etc/systemd/system/coulobre-account-restore@.service.d/database.conf +# Mailbox restores +sudo install -D -m 0644 deploy/systemd/coulobre-account-restore@.service.d/mailbox.conf \ + /etc/systemd/system/coulobre-account-restore@.service.d/mailbox.conf +``` ```sh panel_manage migrate --noinput +sudo systemctl daemon-reload 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. +Operators also need the backup permissions listed above and permission to +view mailbox requests for any backup that includes mail. Select the restore +action on a completed backup. -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 website** restores one file or all website files. A single file + needs an existing parent directory. Select **Replace the existing file at + this path** to permit overwriting. The old and restored copies must fit + within the website quota during staging. The whole website option needs + an empty document root. +- **Restore database** offers databases listed in the backup that still + belong to the account. Use the matching empty managed database and keep + the application disconnected during recovery. If the import fails after + creating objects, inspect the database before attempting another restore. +- **Restore mailbox** offers mailboxes listed in the backup that still + belong to the account. Use a newly provisioned mailbox with no Maildir. + Keep delivery and client access paused for that mailbox during recovery, + with Postfix and Dovecot running for local checks. The restored mailbox + uses the destination credentials and current quota configuration. -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. +The **Backup restores** section shows each target, source backup, operator, +and result. Keep the request records under +`/var/lib/coulobre/account-restores/` while corresponding jobs could still be +delivered. If the panel cannot confirm a restore, check the destination +before submitting another. For resources on separate servers, use the +[account bundle commands](development.md#recover-backups-from-the-bundle). #### Include mailboxes on the same server diff --git a/docs/development.md b/docs/development.md index fe4cbc2..00536ad 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1073,9 +1073,9 @@ 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). +On a single-server installation, operators can restore a website file, an +entire website, a database, or a mailbox from a completed account backup. +See [restoring from the panel](deployment.md#restore-from-local-account-backups-in-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