Use nfs-backup.toml and support completed status
All checks were successful
Build and Release / build-and-release (push) Successful in 1m24s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m24s
Update agent to read nfs-backup.toml instead of legacy backup-status-*.toml files. Add support for 'completed' status string used by backup script. Changes: - Read nfs-backup.toml from status directory - Match 'completed' status as Status::Ok - Simplify file scanning logic for single NFS backup file
This commit is contained in:
@@ -21,7 +21,7 @@ impl BackupCollector {
|
||||
}
|
||||
}
|
||||
|
||||
/// Scan directory for all backup status files
|
||||
/// Scan directory for backup status file (nfs-backup.toml)
|
||||
async fn scan_status_files(&self) -> Result<Vec<PathBuf>, CollectorError> {
|
||||
let status_path = Path::new(&self.status_dir);
|
||||
|
||||
@@ -30,30 +30,15 @@ impl BackupCollector {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
let mut status_files = Vec::new();
|
||||
|
||||
match fs::read_dir(status_path) {
|
||||
Ok(entries) => {
|
||||
for entry in entries {
|
||||
if let Ok(entry) = entry {
|
||||
let path = entry.path();
|
||||
if path.is_file() {
|
||||
if let Some(filename) = path.file_name().and_then(|n| n.to_str()) {
|
||||
if filename.starts_with("backup-status-") && filename.ends_with(".toml") {
|
||||
status_files.push(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
warn!("Failed to read backup status directory: {}", e);
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
// Look for nfs-backup.toml (new NFS-based backup)
|
||||
let nfs_backup_file = status_path.join("nfs-backup.toml");
|
||||
if nfs_backup_file.exists() {
|
||||
return Ok(vec![nfs_backup_file]);
|
||||
}
|
||||
|
||||
Ok(status_files)
|
||||
// No backup status file found
|
||||
debug!("No nfs-backup.toml found in {}", self.status_dir);
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
/// Read a single backup status file
|
||||
@@ -76,7 +61,7 @@ impl BackupCollector {
|
||||
/// Calculate backup status from TOML status field
|
||||
fn calculate_backup_status(status_str: &str) -> Status {
|
||||
match status_str.to_lowercase().as_str() {
|
||||
"success" => Status::Ok,
|
||||
"success" | "completed" => Status::Ok,
|
||||
"warning" => Status::Warning,
|
||||
"failed" | "error" => Status::Critical,
|
||||
_ => Status::Unknown,
|
||||
|
||||
Reference in New Issue
Block a user