diff --git a/datman/src/bin/datman.rs b/datman/src/bin/datman.rs index 06e575e..4fea397 100644 --- a/datman/src/bin/datman.rs +++ b/datman/src/bin/datman.rs @@ -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, diff --git a/datman/src/commands/backup.rs b/datman/src/commands/backup.rs index 69f0787..80a44a8 100644 --- a/datman/src/commands/backup.rs +++ b/datman/src/commands/backup.rs @@ -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(()) +}