cli client: backup: refactor/cleanup of (dry-run) logs
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
4b8395ee0e
commit
a1b800c232
|
@ -851,7 +851,7 @@ async fn create_backup(
|
||||||
let mut catalog = None;
|
let mut catalog = None;
|
||||||
let mut catalog_result_rx = None;
|
let mut catalog_result_rx = None;
|
||||||
|
|
||||||
let printfileinfo = |butype:&str, filename:&str, repo:&pbs_client::BackupRepository, target:&str| {
|
let log_file = |butype: &str, filename: &str, target: &str| {
|
||||||
if dry_run{
|
if dry_run{
|
||||||
println!("Would upload {} '{}' to '{}' as {}", butype, filename, repo, target);
|
println!("Would upload {} '{}' to '{}' as {}", butype, filename, repo, target);
|
||||||
} else {
|
} else {
|
||||||
|
@ -861,18 +861,12 @@ async fn create_backup(
|
||||||
|
|
||||||
for (backup_type, filename, target, size) in upload_list {
|
for (backup_type, filename, target, size) in upload_list {
|
||||||
match (backup_type, dry_run) {
|
match (backup_type, dry_run) {
|
||||||
(BackupSpecificationType::CONFIG, true) => {
|
// dry-run
|
||||||
printfileinfo("config file", &filename, &repo, &target);
|
(BackupSpecificationType::CONFIG, true) => log_file("config file", &filename, &target),
|
||||||
}
|
(BackupSpecificationType::LOGFILE, true) => log_file("log file", &filename, &target),
|
||||||
(BackupSpecificationType::LOGFILE, true) => {
|
(BackupSpecificationType::PXAR, true) => log_file("directory", &filename, &target),
|
||||||
printfileinfo("log file", &filename, &repo, &target);
|
(BackupSpecificationType::IMAGE, true) => log_file("image", &filename, &target),
|
||||||
}
|
// no dry-run
|
||||||
(BackupSpecificationType::PXAR, true) => {
|
|
||||||
printfileinfo("directory", &filename, &repo, &target);
|
|
||||||
}
|
|
||||||
(BackupSpecificationType::IMAGE, true) => {
|
|
||||||
printfileinfo("image", &filename, &repo, &target);
|
|
||||||
}
|
|
||||||
(BackupSpecificationType::CONFIG, false) => {
|
(BackupSpecificationType::CONFIG, false) => {
|
||||||
let upload_options = UploadOptions {
|
let upload_options = UploadOptions {
|
||||||
compress: true,
|
compress: true,
|
||||||
|
@ -880,7 +874,7 @@ async fn create_backup(
|
||||||
..UploadOptions::default()
|
..UploadOptions::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
printfileinfo("config file", &filename, &repo, &target);
|
log_file("config file", &filename, &target);
|
||||||
let stats = client
|
let stats = client
|
||||||
.upload_blob_from_file(&filename, &target, upload_options)
|
.upload_blob_from_file(&filename, &target, upload_options)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -893,7 +887,7 @@ async fn create_backup(
|
||||||
..UploadOptions::default()
|
..UploadOptions::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
printfileinfo("log file", &filename, &repo, &target);
|
log_file("log file", &filename, &target);
|
||||||
let stats = client
|
let stats = client
|
||||||
.upload_blob_from_file(&filename, &target, upload_options)
|
.upload_blob_from_file(&filename, &target, upload_options)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -908,7 +902,7 @@ async fn create_backup(
|
||||||
}
|
}
|
||||||
let catalog = catalog.as_ref().unwrap();
|
let catalog = catalog.as_ref().unwrap();
|
||||||
|
|
||||||
printfileinfo("directory", &filename, &repo, &target);
|
log_file("directory", &filename, &target);
|
||||||
catalog.lock().unwrap().start_directory(std::ffi::CString::new(target.as_str())?.as_c_str())?;
|
catalog.lock().unwrap().start_directory(std::ffi::CString::new(target.as_str())?.as_c_str())?;
|
||||||
|
|
||||||
let pxar_options = pbs_client::pxar::PxarCreateOptions {
|
let pxar_options = pbs_client::pxar::PxarCreateOptions {
|
||||||
|
@ -939,7 +933,7 @@ async fn create_backup(
|
||||||
catalog.lock().unwrap().end_directory()?;
|
catalog.lock().unwrap().end_directory()?;
|
||||||
}
|
}
|
||||||
(BackupSpecificationType::IMAGE, false) => {
|
(BackupSpecificationType::IMAGE, false) => {
|
||||||
printfileinfo("image", &filename, &repo, &target);
|
log_file("image", &filename, &target);
|
||||||
|
|
||||||
let upload_options = UploadOptions {
|
let upload_options = UploadOptions {
|
||||||
previous_manifest: previous_manifest.clone(),
|
previous_manifest: previous_manifest.clone(),
|
||||||
|
|
Loading…
Reference in New Issue