proxmox-backup/pbs-datastore/examples/ls-snapshots.rs
Thomas Lamprecht 33eb23d57e datastore: add snapshot iterator and provide example
will be more used in the future, when the upend-datastore master plan
comes in effect.

also a preparatory work for namespaces

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-04-15 12:38:16 +02:00

35 lines
775 B
Rust

use std::path::PathBuf;
use anyhow::{bail, Error};
use pbs_datastore::{ListGroups, ListSnapshots};
fn run() -> Result<(), Error> {
let base: PathBuf = match std::env::args().skip(1).next() {
Some(path) => path.into(),
None => bail!("no path passed"),
};
for group in ListGroups::new(base.to_owned())? {
let group = group?;
println!("found group {}", group);
let group_path = base.as_path().join(group.to_string());
for snapshot in ListSnapshots::new(group, group_path)? {
println!("\t{}", snapshot?);
}
}
Ok(())
}
fn main() {
std::process::exit(match run() {
Ok(_) => 0,
Err(err) => {
eprintln!("error: {}", err);
1
}
});
}