Add backup all option.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Fixes #35.
This commit is contained in:
parent
a797d9cf46
commit
9e9939d3a9
|
@ -5,7 +5,7 @@ use env_logger::Env;
|
|||
|
||||
use anyhow::bail;
|
||||
use chrono::{DateTime, Local, NaiveDate, NaiveDateTime, TimeZone, Utc};
|
||||
use datman::commands::backup::backup_source_to_destination;
|
||||
use datman::commands::backup::{backup_all_sources_to_destination, backup_source_to_destination};
|
||||
use datman::commands::ilabel::interactive_labelling_session;
|
||||
use datman::commands::init_descriptor;
|
||||
use datman::descriptor::load_descriptor;
|
||||
|
@ -35,7 +35,12 @@ pub enum DatmanCommand {
|
|||
/// Name of the source to back up.
|
||||
source_name: String,
|
||||
|
||||
/// Name of the destination to back up.
|
||||
/// Name of the destination to back up to.
|
||||
destination_name: String,
|
||||
},
|
||||
|
||||
BackupAll {
|
||||
/// Name of the destination to back up to.
|
||||
destination_name: String,
|
||||
},
|
||||
|
||||
|
@ -132,6 +137,18 @@ fn main() -> anyhow::Result<()> {
|
|||
)
|
||||
.unwrap();
|
||||
}
|
||||
DatmanCommand::BackupAll { destination_name } => {
|
||||
let descriptor = load_descriptor(Path::new(".")).unwrap();
|
||||
let destination = &descriptor.piles[&destination_name];
|
||||
backup_all_sources_to_destination(
|
||||
destination,
|
||||
&descriptor,
|
||||
Path::new("."),
|
||||
&destination_name,
|
||||
yama::utils::get_number_of_workers("YAMA_CHUNKERS"),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
DatmanCommand::Extract {
|
||||
source_name,
|
||||
after,
|
||||
|
|
|
@ -284,3 +284,24 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn backup_all_sources_to_destination(
|
||||
dest: &DestPileDescriptor,
|
||||
descriptor: &Descriptor,
|
||||
desc_path: &Path,
|
||||
dest_name: &str,
|
||||
num_workers: u8,
|
||||
) -> anyhow::Result<()> {
|
||||
for (source_name, source_descriptor) in descriptor.source.iter() {
|
||||
backup_source_to_destination(
|
||||
source_descriptor,
|
||||
dest,
|
||||
descriptor,
|
||||
desc_path,
|
||||
source_name.as_str(),
|
||||
dest_name,
|
||||
num_workers,
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue