|
|
@@ -1,5 +1,5 @@
|
|
|
# Cahier des charges — `backupmanager_ynh`
|
|
|
-**Version 4.0 — Finale | 2026-05-08**
|
|
|
+**Version 4.1 — 2026-05-09**
|
|
|
|
|
|
## 1. Vision générale
|
|
|
|
|
|
@@ -50,23 +50,24 @@ backupmanager_ynh/
|
|
|
├── sources/
|
|
|
│ ├── app.py # Flask routes + API REST
|
|
|
│ ├── scheduler.py # APScheduler
|
|
|
-│ ├── db.py # SQLAlchemy
|
|
|
+│ ├── db.py # SQLAlchemy (Job, Run, Destination, Setting)
|
|
|
│ ├── retention.py # Moteur count/daily/gfs
|
|
|
+│ ├── notifications.py # Email SMTP (succès/erreur)
|
|
|
│ ├── jobs/
|
|
|
-│ │ ├── ynh_backup.py # yunohost backup create
|
|
|
+│ │ ├── ynh_backup.py # yunohost backup create/restore
|
|
|
│ │ ├── custom_dir.py # tar + rsync chemins libres
|
|
|
│ │ ├── db_dump.py # mysqldump / pg_dump
|
|
|
-│ │ └── transfer.py # rsync SSH / SFTP
|
|
|
-│ ├── federation/
|
|
|
-│ │ ├── api.py # Endpoints REST
|
|
|
-│ │ ├── client.py # Appels instances distantes
|
|
|
-│ │ └── sync.py # Sync état réseau
|
|
|
+│ │ ├── transfer.py # rsync SSH
|
|
|
+│ │ └── utils.py # sudo_exists/getsize/listdir/read_backup_info
|
|
|
+│ ├── federation/ # Phase 3 (non commencé)
|
|
|
│ └── templates/
|
|
|
│ ├── base.html
|
|
|
│ ├── dashboard_local.html
|
|
|
-│ ├── dashboard_network.html
|
|
|
│ ├── job_form.html
|
|
|
-│ └── job_history.html
|
|
|
+│ ├── job_history.html
|
|
|
+│ ├── restore_confirm.html
|
|
|
+│ ├── settings.html
|
|
|
+│ └── destinations.html
|
|
|
└── doc/
|
|
|
```
|
|
|
|
|
|
@@ -86,23 +87,43 @@ CREATE TABLE jobs (
|
|
|
retention_value INTEGER NOT NULL,
|
|
|
enabled BOOLEAN DEFAULT 1,
|
|
|
core_only BOOLEAN DEFAULT 0,
|
|
|
+ destination_id INTEGER REFERENCES destinations(id),
|
|
|
created_at DATETIME,
|
|
|
updated_at DATETIME
|
|
|
);
|
|
|
|
|
|
--- Historique des exécutions
|
|
|
+-- Destinations de transfert SSH/rsync
|
|
|
+CREATE TABLE destinations (
|
|
|
+ id INTEGER PRIMARY KEY,
|
|
|
+ name TEXT NOT NULL,
|
|
|
+ host TEXT NOT NULL,
|
|
|
+ port INTEGER DEFAULT 22,
|
|
|
+ user TEXT NOT NULL DEFAULT 'root',
|
|
|
+ remote_path TEXT NOT NULL,
|
|
|
+ key_name TEXT, -- fichier clé dans data_dir/keys/
|
|
|
+ enabled BOOLEAN DEFAULT 1,
|
|
|
+ created_at DATETIME
|
|
|
+);
|
|
|
+
|
|
|
+-- Historique des exécutions (backup ET restauration)
|
|
|
CREATE TABLE runs (
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
job_id INTEGER REFERENCES jobs(id),
|
|
|
started_at DATETIME,
|
|
|
finished_at DATETIME,
|
|
|
status TEXT, -- running|success|error
|
|
|
- log_text TEXT,
|
|
|
+ log_text TEXT, -- préfixé [RESTAURATION] si restauration
|
|
|
archive_name TEXT,
|
|
|
size_bytes INTEGER
|
|
|
);
|
|
|
|
|
|
--- Instances distantes enregistrées
|
|
|
+-- Paramètres SMTP et notifications
|
|
|
+CREATE TABLE settings (
|
|
|
+ key TEXT PRIMARY KEY, -- smtp_host, smtp_port, smtp_user, ...
|
|
|
+ value TEXT NOT NULL DEFAULT ''
|
|
|
+);
|
|
|
+
|
|
|
+-- Instances distantes enregistrées (Phase 3)
|
|
|
CREATE TABLE remote_instances (
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
name TEXT NOT NULL, -- ex: "tom"
|
|
|
@@ -354,13 +375,17 @@ rsync -az -e "ssh -i $key -p $port" archive.tar archive.info.json user@host:/hom
|
|
|
- [x] Rétention count et daily
|
|
|
- [x] Dashboard local (jobs + historique + Run now)
|
|
|
|
|
|
-### Phase 2 — Périmètre complet
|
|
|
+### Phase 2 — Périmètre complet ✅ (testé VPS 2026-05-09)
|
|
|
- [x] Jobs custom_dir (exclusions + format YNH compatible)
|
|
|
- [x] Jobs mysql et postgresql
|
|
|
-- [x] Restauration complète custom_dir
|
|
|
-- [x] Restauration complète DB (mysql + postgresql)
|
|
|
-- [x] Destinations rsync SSH / SFTP
|
|
|
-- [x] Notifications email
|
|
|
+- [x] Restauration complète custom_dir, mysql, postgresql, ynh_app, ynh_system
|
|
|
+- [x] Restaurations tracées dans l'historique du job
|
|
|
+- [x] Destinations rsync SSH
|
|
|
+- [x] Transfert automatique post-backup
|
|
|
+- [x] Nommage unique (suffixe _2, _3… si doublon du jour)
|
|
|
+- [x] Notifications email SMTP (succès/erreur)
|
|
|
+- [x] Liste BDD live dans le formulaire (mysql/postgresql)
|
|
|
+- [x] Accès archives root-owned via sudo (stat/find/tar/rsync)
|
|
|
|
|
|
### Phase 3 — Fédération
|
|
|
- [ ] API REST complète
|
|
|
@@ -377,4 +402,4 @@ rsync -az -e "ssh -i $key -p $port" archive.tar archive.info.json user@host:/hom
|
|
|
|
|
|
---
|
|
|
|
|
|
-*backupmanager_ynh — CDC v4.0 — 2026-05-08 | Avancement mis à jour le 2026-05-08*
|
|
|
+*backupmanager_ynh — CDC v4.1 — Avancement mis à jour le 2026-05-09 | Phase 2 complète ✅ | Phase 3 à démarrer*
|