feat: nexus backup ohne Migration, install.sh sichert die Datenbank vor jedem Update und nennt sie beim Rückfall

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 09:32:13 +01:00
parent a4f90e82b8
commit f80566290b
3 changed files with 109 additions and 3 deletions

View File

@ -27,6 +27,7 @@ Aufruf:
nexus model add --name N --engine maya --maya-config PFAD.json [--gpus 0,1] [--disabled]
nexus model list | enable --name N | disable --name N | discover [--engine llama.cpp|ollama|maya]
nexus diag [--out DATEI.tar.gz] [--ohne-engine-logs] Diagnose-Archiv ohne Prompts und Keys
nexus backup [--out DATEI.db] Kopie der Datenbank (ohne sie zu migrieren; auch bei laufendem Gateway)
nexus help Diese Hilfe
Die Konfiguration kommt aus --config, sonst NEXUS_CONFIG, sonst ./config.toml, sonst gelten Standardwerte.
@ -45,6 +46,7 @@ async fn main() -> ExitCode {
Some("key") => admin::key(&args[1..]),
Some("model") => admin::model(&args[1..]).await,
Some("diag") => diag::command(&args[1..]),
Some("backup") => backup(&args[1..]),
Some("help") | Some("--help") | None => {
print!("{HILFE}");
ExitCode::SUCCESS
@ -96,3 +98,33 @@ fn config_path(args: &[String]) -> Result<Option<PathBuf>, String> {
_ => Err("Aufruf: nexus selftest [--config PFAD]".to_string()),
}
}
/// `nexus backup`: Kopie der Datenbank, Standard `data_dir/backups/nexus-<zeit>.db`.
fn backup(args: &[String]) -> ExitCode {
let run = || -> Result<PathBuf, String> {
let flags = cli::Flags::parse(args, &["out", "config"], &[])?;
let config = cli::load_config(&flags)?;
let db = config.db_path();
if !db.is_file() {
return Err(format!("Es gibt keine Datenbank unter {}.", db.display()));
}
let out = flags.get("out").map(PathBuf::from).unwrap_or_else(|| {
config.data_dir.join("backups").join(format!(
"nexus-{}.db",
nexus_core::now_iso8601().replace([':', '-'], "")
))
});
nexus_store::backup_file(&db, &out).map_err(|e| e.to_string())?;
Ok(out)
};
match run() {
Ok(out) => {
println!("Sicherung geschrieben: {}", out.display());
ExitCode::SUCCESS
}
Err(message) => {
eprintln!("{message}");
ExitCode::FAILURE
}
}
}