diff --git a/pbs-datastore/src/backup_info.rs b/pbs-datastore/src/backup_info.rs index 1902e135..522bc059 100644 --- a/pbs-datastore/src/backup_info.rs +++ b/pbs-datastore/src/backup_info.rs @@ -369,6 +369,7 @@ impl BackupInfo { Ok(files) } + #[deprecated = "move to datastore"] pub fn list_backup_groups(base_path: &Path) -> Result, Error> { let mut list = Vec::new(); diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index 1d389d58..8a1c6fa0 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -19,7 +19,7 @@ use proxmox_sys::{task_log, task_warn}; use pbs_api_types::{ Authid, ChunkOrder, DataStoreConfig, DatastoreTuning, GarbageCollectionStatus, HumanByte, - Operation, UPID, + Operation, BACKUP_ID_REGEX, BACKUP_TYPE_REGEX, UPID, }; use pbs_config::{open_backup_lockfile, BackupLockGuard, ConfigVersionCache}; @@ -552,6 +552,38 @@ impl DataStore { } } + /// Get a in-memory vector for all top-level backup groups of a datatstore + pub fn list_backup_groups(&self) -> Result, Error> { + let mut list = Vec::new(); + + proxmox_sys::fs::scandir( + libc::AT_FDCWD, + &self.base_path(), + &BACKUP_TYPE_REGEX, + |l0_fd, backup_type, file_type| { + if file_type != nix::dir::Type::Directory { + return Ok(()); + } + proxmox_sys::fs::scandir( + l0_fd, + backup_type, + &BACKUP_ID_REGEX, + |_, backup_id, file_type| { + if file_type != nix::dir::Type::Directory { + return Ok(()); + } + + list.push(BackupGroup::new(backup_type, backup_id)); + + Ok(()) + }, + ) + }, + )?; + + Ok(list) + } + pub fn list_images(&self) -> Result, Error> { let base = self.base_path();