From 6a578732f9bf45d7325fe2154496d73995659ae0 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Wed, 3 Sep 2025 21:50:44 +0200 Subject: backup: truncating logs even when tar fails --- backup/src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'backup/src') diff --git a/backup/src/main.rs b/backup/src/main.rs index 6981389..3433b68 100644 --- a/backup/src/main.rs +++ b/backup/src/main.rs @@ -162,13 +162,14 @@ fn main() -> Result<(), Box> { } let tar_status = tar_cmd.status()?; - if !tar_status.success() { - return Err("ERROR: Fehler beim Erstellen des Tar-Backups".into()); - } - + // Log-Dateien behandeln cmd!("find", "/var/log", "-type", "f", "-name", "*.log", "-exec", "truncate", "-s", "0", "{}", ";").run()?; cmd!("find", "/var/log", "-type", "f", "-name", "*.gz", "-exec", "rm", "-f", "{}", ";").run()?; + + if !tar_status.success() { + return Err("ERROR: Fehler beim Erstellen des Tar-Backups".into()); + } println!("INFO: Backup erfolgreich als: {}", backup_path.display()); Ok(()) -- cgit v1.2.3