Back up and recover remote mailboxes from the panel
Coulobre Panel CI / Checks (Python 3.12) (pull_request) Canceled after 0s
Coulobre Panel CI / Checks (Python 3.14) (pull_request) Canceled after 0s

This commit is contained in:
parkel committed 2026-11-21 22:18:59 +01:00
1 parent 13cb45dfe4
commit 386525d314
13 files changed
+510 -24

No files matched your search

+113 -7
View File
@@ -586,8 +586,9 @@ worker delivery from recreating an expired archive.
#### Restore from local account backups in the panel
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.
backup worker access to it. Website and MariaDB restores use the backup
host. To restore to a separate mail server, use the
[remote mailbox setup](#include-mailboxes-on-a-separate-server).
```sh
sudo groupadd --system coulobre-restore-requests
@@ -644,7 +645,7 @@ action on a completed backup.
- **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
with Postfix and Dovecot running on the destination. The restored mailbox
uses the destination credentials and current quota configuration.
The **Backup restores** section shows each target, source backup, operator,
@@ -652,7 +653,8 @@ 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).
[account bundle commands](development.md#recover-backups-from-the-bundle)
or the remote mailbox action below.
##### Run a backup and restore drill
@@ -690,9 +692,113 @@ starting or scheduling an account backup. They can also edit an existing
schedule that includes mail. If you disable mailbox backups while such a
schedule is enabled, the subsequent jobs report a failure until you adjust
the schedule or re-enable local mailbox backups. Provision all listed
mailboxes before requesting a backup with mail. For mailboxes on a separate
server, use the
[bundle workflow for separate nodes](development.md#bundle-backups-from-separate-nodes).
mailboxes before requesting a backup with mail.
#### Include mailboxes on a separate server
Enable local account backups on the panel host and provision the
mailboxes on the [separate mail node](#provision-mail-and-dns-on-separate-servers).
Upgrade Coulobre on both hosts. The website, database dumps, and completed
ZIP stay on the backup host. The mail node streams the native snapshots
over SSH and uses temporary disk space while collecting or restoring a
mailbox.
Choose which operations to enable. The examples enable both; use just
`backup` in the loops if you only want to collect mail.
On the backup host, create a dedicated identity and SSH key for each
operation, and install its relay socket and service.
```sh
sudo apt install openssh-client
sudo install -d -m 0755 /etc/coulobre-remote
sudo install -m 0644 deploy/openssh/mail-archive-client.conf.example \
/etc/coulobre-remote/mail-archive.conf
sudoedit /etc/coulobre-remote/mail-archive.conf
for action in backup restore; do
unit="coulobre-mail-archive-$action"
path="/etc/coulobre-remote/mail-archive-$action"
sudo useradd --system --user-group --no-create-home --home-dir /nonexistent \
--shell /usr/sbin/nologin "$unit"
sudo install -d -o root -g "$unit" -m 0750 "$path"
sudo ssh-keygen -t ed25519 -N '' -f "$path/id_ed25519"
sudo chown "$unit:$unit" "$path/id_ed25519"
sudo install -m 0644 "deploy/systemd/$unit.socket" \
"deploy/systemd/$unit@.service" /etc/systemd/system/
sudo install -D -m 0644 "deploy/systemd/$unit@.service.d/relay.conf" \
"/etc/systemd/system/$unit@.service.d/relay.conf"
sudo cat "$path/id_ed25519.pub"
done
```
Point the SSH aliases at the mail node that serves these mailboxes. Add
its verified host key to each operation's `known_hosts` file. Keep both
aliases pointed at the same node while jobs are queued or may be retried.
On the mail node, save the sender's separate public keys as
`backup.pub` and `restore.pub`. Install the receiver accounts, sockets,
and forced commands.
```sh
sudo apt install openssh-server socat
sudo install -d -m 0755 /etc/ssh/coulobre-node-keys
for action in backup restore; do
unit="coulobre-mail-archive-$action"
sudo useradd --system --user-group --no-create-home --home-dir / \
--shell /bin/sh "$unit"
sudo install -m 0644 "$action.pub" "/etc/ssh/coulobre-node-keys/$unit"
sudo install -m 0644 "deploy/systemd/$unit.socket" \
"deploy/systemd/$unit@.service" /etc/systemd/system/
sudo systemctl enable --now "$unit.socket"
done
sudo install -m 0644 deploy/openssh/coulobre-mail-archive.conf.example \
/etc/ssh/sshd_config.d/00-coulobre-mail-archive.conf
sudo install -m 0644 deploy/tmpfiles.d/coulobre-mail-archive.conf \
/etc/tmpfiles.d/coulobre-mail-archive.conf
sudo sshd -t
sudo systemctl reload-or-restart ssh.service
sudo systemctl start systemd-tmpfiles-clean.timer
```
Return to the backup host. Enable the corresponding relay sockets and
authorize the operations for the account services.
```sh
sudo install -D -m 0644 deploy/systemd/coulobre-account-backup@.service.d/remote-mail.conf \
/etc/systemd/system/coulobre-account-backup@.service.d/remote-mail.conf
sudo systemctl enable --now coulobre-mail-archive-backup.socket
# For restores, install the account restore socket and worker access first.
sudo install -D -m 0644 deploy/systemd/coulobre-account-restore@.service.d/remote-mail.conf \
/etc/systemd/system/coulobre-account-restore@.service.d/remote-mail.conf
sudo systemctl enable --now coulobre-mail-archive-restore.socket
```
Use `COULOBRE_REMOTE_ACCOUNT_BACKUP_MAIL=1` and, if enabled,
`COULOBRE_REMOTE_MAILBOX_RESTORE=1` in `/etc/coulobre/panel.env`.
Each operation takes one transport. Clear its local setting when
switching that operation to SSH. Apply migrations, reload systemd, and
restart the panel, scheduler and backup worker.
Select **Include mailboxes** in manual or scheduled backups. A failed or
interrupted transfer reports where mail collection stopped and keeps the
incomplete backup out of the ready archives and retention count.
For recovery, pause delivery and client access for the selected mailbox.
Use **Restore mailbox** with the matching, provisioned destination and
an absent Maildir. If the connection drops before the result is confirmed,
use **Retry remote restore** while the source archive is available. The
mail node records results by restore ID and checks the archive checksum
and destination before writing. If it reports an interrupted restore,
inspect the destination before opening a new request. Keep the mail
node's restore journal under `/var/lib/coulobre/mail-archive-restores/`
while corresponding jobs can still be retried. The cleanup rule removes
abandoned transfer staging files after one day.
For a recovery drill, follow the [backup and restore drill](#run-a-backup-and-restore-drill)
with the mailbox stored on the other node. Verify that the backup on the
panel host includes the website, SQL dump, and test message, and that the
selected message is recovered on the mail node.
## Show local database and mailbox connection details