feat: regelmäßige Sicherung im Gateway mit Rotation, Prüfung und 0600 (#1222)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmHhg7hLrpgArYQDUZQTAJ
This commit is contained in:
2026-11-23 16:41:31 +01:00
parent 6005098247
commit 2687790a45
9 changed files with 548 additions and 21 deletions

View File

@ -44,6 +44,12 @@ pub struct Config {
pub metrics_rollup5_days: u32,
/// Wie lange die Stundenwerte der Zeitreihen bleiben (Tage); `0` = unbegrenzt.
pub metrics_rollup60_days: u32,
/// Regelmäßige Sicherung der Datenbank nach `data_dir/backups/nexus-auto-<zeit>.db` (→ #1222).
pub backup_enabled: bool,
/// Abstand der Sicherungen in Stunden (mindestens 1).
pub backup_interval_hours: u64,
/// Wie viele eigene Sicherungen (`nexus-auto-*`) bleiben (mindestens 1).
pub backup_keep: usize,
/// Einstellungen des Schedulers (Abschnitt `[scheduler]`).
pub scheduler: SchedulerConfig,
/// Rohe Einstellungen des llama.cpp-Adapters (Abschnitt `[llama_cpp]`).
@ -112,6 +118,9 @@ impl Default for Config {
metrics_retention_days: 7,
metrics_rollup5_days: 35,
metrics_rollup60_days: 365,
backup_enabled: true,
backup_interval_hours: 24,
backup_keep: 14,
scheduler: SchedulerConfig::default(),
llama_cpp: toml::Table::new(),
ollama: toml::Table::new(),
@ -150,6 +159,11 @@ impl Config {
self.log_level
)));
}
if self.backup_interval_hours == 0 || self.backup_keep == 0 {
return Err(Error::Config(
"backup_interval_hours und backup_keep müssen mindestens 1 sein".to_string(),
));
}
if self.data_dir.as_os_str().is_empty() {
return Err(Error::Config("data_dir darf nicht leer sein".to_string()));
}