mirror of
https://git.proxmox.com/git/vma-to-pbs
synced 2025-05-28 18:22:40 +00:00
add option to skip vmids whose backups failed to upload
Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
This commit is contained in:
parent
207b83fe4c
commit
54ad876f25
@ -54,6 +54,9 @@ Options:
|
|||||||
File containing a comment/notes
|
File containing a comment/notes
|
||||||
[--log-file <LOG_FILE>]
|
[--log-file <LOG_FILE>]
|
||||||
Log file
|
Log file
|
||||||
|
--skip-failed
|
||||||
|
Skip VMIDs that failed to be uploaded and continue onto the next VMID if a dump directory
|
||||||
|
is specified.
|
||||||
-y, --yes
|
-y, --yes
|
||||||
Automatic yes to prompts
|
Automatic yes to prompts
|
||||||
-h, --help
|
-h, --help
|
||||||
@ -74,6 +77,7 @@ fn parse_args() -> Result<BackupVmaToPbsArgs, Error> {
|
|||||||
"--compress",
|
"--compress",
|
||||||
"-e",
|
"-e",
|
||||||
"--encrypt",
|
"--encrypt",
|
||||||
|
"--skip-failed",
|
||||||
"-y",
|
"-y",
|
||||||
"--yes",
|
"--yes",
|
||||||
];
|
];
|
||||||
@ -123,6 +127,7 @@ fn parse_args() -> Result<BackupVmaToPbsArgs, Error> {
|
|||||||
let key_password_file: Option<OsString> = args.opt_value_from_str("--key-password-file")?;
|
let key_password_file: Option<OsString> = args.opt_value_from_str("--key-password-file")?;
|
||||||
let notes_file: Option<OsString> = args.opt_value_from_str("--notes-file")?;
|
let notes_file: Option<OsString> = args.opt_value_from_str("--notes-file")?;
|
||||||
let log_file_path: Option<OsString> = args.opt_value_from_str("--log-file")?;
|
let log_file_path: Option<OsString> = args.opt_value_from_str("--log-file")?;
|
||||||
|
let skip_failed = args.contains("--skip-failed");
|
||||||
let yes = args.contains(["-y", "--yes"]);
|
let yes = args.contains(["-y", "--yes"]);
|
||||||
|
|
||||||
match (encrypt, keyfile.is_some()) {
|
match (encrypt, keyfile.is_some()) {
|
||||||
@ -350,6 +355,7 @@ fn parse_args() -> Result<BackupVmaToPbsArgs, Error> {
|
|||||||
let options = BackupVmaToPbsArgs {
|
let options = BackupVmaToPbsArgs {
|
||||||
pbs_args,
|
pbs_args,
|
||||||
grouped_vmas,
|
grouped_vmas,
|
||||||
|
skip_failed,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(options)
|
Ok(options)
|
||||||
|
@ -32,6 +32,7 @@ const VMA_CLUSTER_SIZE: usize = 65536;
|
|||||||
pub struct BackupVmaToPbsArgs {
|
pub struct BackupVmaToPbsArgs {
|
||||||
pub pbs_args: PbsArgs,
|
pub pbs_args: PbsArgs,
|
||||||
pub grouped_vmas: HashMap<String, Vec<VmaBackupArgs>>,
|
pub grouped_vmas: HashMap<String, Vec<VmaBackupArgs>>,
|
||||||
|
pub skip_failed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PbsArgs {
|
pub struct PbsArgs {
|
||||||
@ -478,12 +479,18 @@ pub fn vma2pbs(args: BackupVmaToPbsArgs) -> Result<(), Error> {
|
|||||||
for (_, vma_group) in args.grouped_vmas {
|
for (_, vma_group) in args.grouped_vmas {
|
||||||
for backup_args in vma_group {
|
for backup_args in vma_group {
|
||||||
if let Err(e) = upload_vma_file(pbs_args, &backup_args) {
|
if let Err(e) = upload_vma_file(pbs_args, &backup_args) {
|
||||||
eprintln!(
|
let err_msg = format!(
|
||||||
"Failed to upload vma file at {:?} - {e}",
|
"Failed to upload vma file at {:?} - {e}",
|
||||||
backup_args.vma_file_path.unwrap_or("(stdin)".into()),
|
backup_args.vma_file_path.unwrap_or("(stdin)".into()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if args.skip_failed {
|
||||||
|
eprintln!("{}", err_msg);
|
||||||
println!("Skipping VMID {}", backup_args.backup_id);
|
println!("Skipping VMID {}", backup_args.backup_id);
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
bail!(err_msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user