docs: describe scheduled S3 mirror client (#360)
Heimdall Gitea / Detect CI scope (push) Successful in 5s
Heimdall Gitea / Build and tests (push) Successful in 17m6s
Heimdall Gitea / Build and scan server image (push) Skipped
Heimdall Gitea / Build and scan agent image (push) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Skipped
Heimdall Gitea / Publish versioned installer release (push) Skipped
Heimdall Gitea / CI policy (push) Successful in 2s

Co-authored-by: Arnaud Dartois <admin@tordais.cc>
This commit was merged in pull request #360.
This commit is contained in:
arnaud.dartois authored and Arnaud Dartois committed 2026-11-13 10:01:35 +01:00
1 parent bdffcf4732
commit af7a1b9585
2 files changed
+18 -5

No files matched your search

+15 -4
View File
@@ -6,11 +6,17 @@ Sauvegarde automatisée de PostgreSQL (quotidien) et RustFS/S3 (hebdomadaire) av
| Composant | Fréquence | Script | Rétention |
|---|---|---|---|
| PostgreSQL `pg_dump` | Quotidien 02:00 UTC | `docker/scripts/backup.sh` | 30 jours (local) + 30 jours (S3) |
| RustFS `mc mirror` | Hebdo dimanche 03:00 UTC | `docker/scripts/backup-rustfs.sh` | 12 semaines |
| Volume Central (objets locaux + clés Data Protection) | Quotidien 02:15 UTC | `docker/scripts/backup-protected-data.sh` | 30 jours (local); cycle S3 selon la politique de bucket |
| PostgreSQL `pg_dump` | Quotidien 02:00, heure du conteneur | `docker/scripts/backup.sh` | 30 jours (local) + 30 jours (S3) |
| Miroir RustFS/S3 (`aws s3 sync` dans le Compose livré) | Dimanche 03:00, heure du conteneur | `docker/scripts/backup-rustfs.sh` | 12 semaines |
| Volume Central (objets locaux + clés Data Protection) | Quotidien 02:15, heure du conteneur | `docker/scripts/backup-protected-data.sh` | 30 jours (local); cycle S3 selon la politique de bucket |
| Test de restauration | Manuel / CI | `docker/scripts/test-backup-restore.sh` | — |
Le Compose backup définit `TZ` à `Europe/Paris` par défaut; ces horaires
s'appliquent donc à l'heure locale de Paris, avec les changements saisonniers.
Définir `TZ` avec un identifiant de fuseau IANA pour choisir un autre fuseau.
Les scripts horodatent leurs archives en UTC; l'heure du nom d'archive peut donc
différer de l'heure locale d'exécution.
## Activation
### Compose facultatif séparé
@@ -25,6 +31,10 @@ rejoint le réseau partagé et tourne dans un conteneur PostgreSQL 17-alpine
avec crontab interne, AWS CLI et GNU coreutils (pour le calcul portable des seuils
de rétention Alpine). Les dumps sont stockés dans `backup_data`; l'upload
RustFS/S3 est facultatif.
Le service fourni installe AWS CLI, pas MinIO Client : `backup-rustfs.sh`
utilise donc `aws s3 sync` avec l'endpoint configuré. Le script conserve un
chemin de compatibilité `mc mirror` si `mc` est déjà présent dans une image ou
un environnement personnalisé; il ne télécharge ni n'installe ce binaire.
Le service monte aussi le volume `heimdall_data` du Compose Central : les
objets stockés localement et les clés Data Protection sont archivés ensemble.
Le nom par défaut est `docker_heimdall_data`, pour le projet Compose du dépôt.
@@ -50,6 +60,7 @@ configurés. Garder l’application Central arrêtée pendant une restauration.
| `BACKUP_RETENTION_DAYS` | `30` | Rétention jours (PostgreSQL) |
| `BACKUP_RETENTION_WEEKS` | `12` | Rétention semaines (RustFS) |
| `BACKUP_LOCAL_DIR` | `/backups` | Répertoire local dans le conteneur |
| `TZ` | `Europe/Paris` | Fuseau utilisé par le planning cron du conteneur |
## Structure des backups
@@ -321,6 +332,6 @@ docker compose -f docker/docker-compose.backup.yml exec backup ls -la /var/log/b
- **pg_dump --format=custom** nécessite `pg_restore` pour la restauration (pas `psql`)
- Le conteneur backup utilise `postgres:17-alpine` pour avoir `pg_dump` et `pg_restore`
- mc (MinIO Client) est installé au démarrage du conteneur (curl depuis dl.min.io)
- Le Compose livré installe `aws-cli`, Bash et GNU coreutils; il n'installe pas MinIO Client. Le script de miroir préfère `mc` s'il est déjà fourni, sinon utilise AWS CLI `s3 sync`.
- Si S3 n'est pas configuré, le backup est local uniquement (volume Docker)
- La restauration DROP la base existante — toujours vérifier le `--dry-run` d'abord
+3 -1
View File
@@ -15,6 +15,8 @@ Use this workflow when changing `docker/scripts/backup*.sh`, `docker/scripts/res
- `backup-protected-data.sh` archives the Central data volume, including local objects and `dp-keys`. Restore with `restore-protected-data.sh` only while Central is stopped. The script overlays files and deliberately keeps unrelated target files.
- Preserve the entire Data Protection ring and `dp-cert.pfx` together. Expired keys can still be required to unprotect stored payloads; never replace/delete one file as part of a restore. Heimdall has no validated manual rotation process for the certificate that protects the ring at rest; keep certificate rotation separate until tested against existing payloads. See `docker/backup/README.md`.
- PostgreSQL and protected-volume archives are separate snapshots. The application does not coordinate them into one atomic point in time.
- The scheduled backup Compose installs Alpine `aws-cli`, `bash`, and GNU `coreutils`; it does not install MinIO Client (`mc`). `backup-rustfs.sh` uses `aws s3 sync` in this shipped container and only selects `mc mirror` when `mc` is already present in a customized environment. Keep `docker/backup/README.md` aligned with this effective default and never document a retired `mc` download as an installer step.
- The scheduled Compose sets `TZ` to `Europe/Paris` by default. Cron times in `docker-compose.backup.yml` use the container timezone, while scripts use UTC for archive timestamps and retention cutoffs. Document both clocks separately and describe any changed `TZ` as an operator configuration, not as UTC scheduling.
- `test-backup-restore.sh` uses a named isolated network, `tmpfs` for its disposable PostgreSQL data directory, and a temporary host directory. Its cleanup must leave no container, network, or anonymous volume.
## Acceptance
@@ -24,7 +26,7 @@ Use this workflow when changing `docker/scripts/backup*.sh`, `docker/scripts/res
3. For changes to volume-level restore or Compose behavior, build a disposable Compose project from the checkout with unique project name, generated credentials, and generated named volumes. Dump from one PostgreSQL volume and restore into a different volume; check a known row. Archive and remove synthetic files from the protected volume, restore them, and compare digests and key permissions.
4. Measure only the synthetic restore duration and label it as a local fixture measurement. Do not present it as a production RTO. Derive the configured backup interval separately; do not imply it is a measured production RPO. For actual RPO/RTO drills, use the timestamp, resource, host, and repeated-run procedure in `docker/backup/README.md` and record the operator-approved target separately.
5. Install an EXIT cleanup trap before build/start. Tear down only the disposable project with `docker compose -p <name> down --volumes --remove-orphans`; query its Compose project labels and confirm zero containers, volumes, and networks. Remove generated files even on a failed assertion. These fixtures use upstream PostgreSQL/RustFS images and build no local image unless a recipe change explicitly adds one; retain those upstream images. If adding a local build, record its unique tag and remove/verify that exact tag in the same trap after teardown. Never use `--rmi all` or broad prune commands.
6. The scheduled backup image installs Alpine's `aws-cli`, `bash`, and GNU `coreutils` (`date -d` retention cutoffs do not work in BusyBox). Do not rely on the retired MinIO client download URL. The scripts pass configured S3 credentials explicitly to AWS CLI for each invocation.
6. The scheduled backup image installs Alpine's `aws-cli`, `bash`, and GNU `coreutils` (`date -d` retention cutoffs do not work in BusyBox), not MinIO Client. `backup-rustfs.sh` therefore uses `aws s3 sync`; its `mc mirror` branch is only a fallback when a customized image already provides `mc`. Do not rely on the retired MinIO client download URL. The AWS CLI path passes configured S3 credentials explicitly for each invocation.
7. Validate S3 behavior with a disposable RustFS service, unique Compose project/network/volumes and generated keys. Create a synthetic row, run `backup.sh`, verify both dated and `latest.sql.gz` objects, mutate the row, then run `restore.sh --latest --yes` and verify the prior value. Add ancient synthetic daily and weekly keys and confirm both retention jobs delete them. Also exercise `backup-protected-data.sh` upload and `backup-rustfs.sh` mirror/manifest where changed.
8. Keep real-volume production recovery and production RPO/RTO open until validated on their actual service and data.