Add backup and restore scripts

This commit is contained in:
2026-09-18 12:24:08 +03:00
parent 2fc905986a
commit a98df9c264
8 changed files with 237 additions and 7 deletions
+40 -2
View File
@@ -48,9 +48,15 @@ On Windows PowerShell:
Put the generated 24-character value in `RC_DES_KEY` in `.env`.
## Prepare Linux data directories
## Persistent Stalwart data
The Stalwart container runs as uid/gid `2000`. Create the bind-mounted directories and set the required ownership before starting the stack:
Stalwart configuration, mail, and certificates are stored in Docker-managed volumes. This avoids host filesystem ownership problems after Docker Desktop or WSL restarts. The `stalwart-data-init` service assigns the ownership Stalwart requires before it starts.
Do not use `docker compose down --volumes` or `docker volume rm` for this project unless you intend to permanently delete Stalwart's configuration and mail data.
To protect against laptop loss, disk failure, or a Docker Desktop reset, back up the three `eternitymail-stalwart-*` volumes to storage outside Docker Desktop. Docker volumes protect data across normal container recreation, not a destroyed Docker data disk.
The legacy Linux bind-mount preparation command applies only to deployments which still use `DATA_ROOT` bind mounts:
```bash
chmod +x scripts/setup-data-dirs.sh
@@ -104,6 +110,38 @@ docker compose down
Persistent data is stored under `DATA_ROOT` in the `stalwart`, `roundcube-db`, and `roundcube-config` directories.
## Backup, restore, and server migration
Backups include Stalwart configuration, certificates, mailboxes, Roundcube's database/configuration, `.env`, and `docker-compose.yml`. The backup stops the mail services briefly so the RocksDB and MariaDB files are consistent, then starts them again.
On Linux, create a backup outside Docker Desktop or the server's Docker data disk:
```bash
chmod +x scripts/backup-server.sh scripts/restore-server.sh
./scripts/backup-server.sh /mnt/backup/eternitymail
```
On Windows PowerShell:
```powershell
.\scripts\backup-server.ps1 -Destination D:\Backups\EternityMail
```
Restore that backup to Docker Desktop with:
```powershell
.\scripts\restore-server.ps1 -Archive D:\Backups\EternityMail\eternitymail-<timestamp>.tar.gz
```
Copy the resulting `.tar.gz` archive, this repository, and the `ep-roundcube-skin` checkout to the new Linux server. Install Docker Engine with the Compose plugin, then restore from the repository root:
```bash
sudo ./scripts/restore-server.sh /mnt/backup/eternitymail/eternitymail-<timestamp>.tar.gz
docker compose ps
```
Restore refuses to replace an existing deployment unless `--force` (Linux) or `-Force` (PowerShell) is supplied. That option stops the stack and permanently replaces its Stalwart volumes and Roundcube bind-mount data. Keep the same `.env` from the archive, particularly `RC_DES_KEY`, passwords, hostname, and recovery administrator setting. Before moving production traffic, update the new server's DNS, firewall, and TLS configuration, then verify IMAPS and SMTP.
## Network ports
The host bindings are configurable in `.env`: