[pbs-devel] [PATCH vma-to-pbs v4 2/6] add support for bulk import of a dump directory

Filip Schauer f.schauer at proxmox.com
Mon Nov 11 14:13:45 CET 2024


Superseded by:
https://lists.proxmox.com/pipermail/pbs-devel/2024-November/011353.html


On 04/11/2024 14:06, Fabian Grünbichler wrote:
> grouped_vmas should still be a map, not a vec of vec.. e.g., something 
> like this (requires some more adaptation - while this could use 
> itertools, I don't think it's worth to pull that in if the same can be 
> had with a single fold invocation): @@ -298,12 +298,16 @@ fn 
> parse_args() -> Result<BackupVmaToPbsArgs, Error> { 
> vmas.sort_by_key(|d|d.backup_time); let total_vma_count = vmas.len(); 
> - let mut grouped_vmas: Vec<_> = vmas - .into_iter() - 
> .into_group_map_by(|d|d.backup_id.clone()) - .into_values() - 
> .collect(); - grouped_vmas.sort_by_key(|d|d[0].backup_id.clone()); + 
> let grouped_vmas = vmas.into_iter().fold( + HashMap::new(), + |mut 
> grouped: HashMap<String, Vec<VmaBackupArgs>>, vma_args|{ + grouped + 
> .entry(vma_args.backup_id.clone()) + .or_default() + .push(vma_args); 
> + grouped + }, + ); log::info!( "Found {} backup archive(s) of {} 
> different VMID(s):", @@ -311,12 +315,8 @@ fn parse_args() -> 
> Result<BackupVmaToPbsArgs, Error> { grouped_vmas.len() ); - for 
> vma_group in &grouped_vmas { - log::info!( - "- VMID {}: {} backups", 
> - vma_group[0].backup_id, - vma_group.len() - ); + for (vma_group, 
> vma_args) in &grouped_vmas { + log::info!("- VMID {}: {} backups", 
> vma_group, vma_args.len()); } if !yes {

done


On 04/11/2024 14:06, Fabian Grünbichler wrote:
>> +        println!(
>> +            "Found {} backup archive(s) of {} different VMID(s):",
>> +            total_vma_count,
>> +            grouped_vmas.len()
>> +        );
> if we don't find any, we should print something else here and exit?

done with `bail!` in v5


On 04/11/2024 14:06, Fabian Grünbichler wrote:
>> +        if !yes {
>> +            loop {
>> +                eprint!("Proceed with the bulk import? (y/n): ");
>> +                let mut line = String::new();
>> +
>> +                BufReader::new(std::io::stdin()).read_line(&mut line)?;
>> +                let trimmed = line.trim();
>> +                if trimmed == "y" || trimmed == "Y" {
>> +                    break;
>> +                } else if trimmed == "n" || trimmed == "N" {
>> +                    bail!("Bulk import was not confirmed.");
>> +                }
> this maybe should mimic what we do in proxmox_router when prompting 
> for confirmation? e.g., flush stdout, have a default value, ..? should 
> we abort after a few loops?

Changed in v5 to mimic the behaviour of the confirmation prompt in
proxmox_router. (bail on invalid input)
Also made Y the default choice.





More information about the pbs-devel mailing list