borgbackup/sync/
create.rs1use log::{debug, info};
2
3use crate::common::{create_fmt_args, create_parse_output, CommonOptions, CreateOptions};
4use crate::errors::CreateError;
5use crate::output::create::Create;
6use crate::sync::execute_borg;
7
8pub fn create(
17 options: &CreateOptions,
18 common_options: &CommonOptions,
19) -> Result<Create, CreateError> {
20 let local_path = common_options.local_path.as_ref().map_or("borg", |x| x);
21
22 let args = create_fmt_args(options, common_options, false);
23 debug!("Calling borg: {local_path} {args}");
24 let args = shlex::split(&args).ok_or(CreateError::ShlexError)?;
25 let res = execute_borg(local_path, args, &options.passphrase)?;
26
27 let stats = create_parse_output(res)?;
28
29 info!("Finished creating archive");
30
31 Ok(stats)
32}