mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-04-29 10:27:38 +00:00
push: reduce calls to list_snapshots on target side
instead of calling this three times, call it once: retrieving the highest backup timestamp doesn't need its own request, it can re-use the "main" result, the corresponding helper can thus be dropped. remove_vanished can re-use the earlier result - if anybody prunes the backup group or adds new snapshots while the sync is running, the whole group sync is racy and might cause spurious errors anyway. since re-syncing the last already existing snapshot is not possible at the moment, the code can also be simplified by treating such a snapshots already fully synced. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
56ab13f0e2
commit
0bcbb1badd
@ -579,16 +579,6 @@ async fn fetch_target_snapshots(
|
||||
Ok(snapshots)
|
||||
}
|
||||
|
||||
async fn fetch_previous_backup_time(
|
||||
params: &PushParameters,
|
||||
target_namespace: &BackupNamespace,
|
||||
group: &BackupGroup,
|
||||
) -> Result<Option<i64>, Error> {
|
||||
let mut snapshots = fetch_target_snapshots(params, target_namespace, group).await?;
|
||||
snapshots.sort_unstable_by(|a, b| a.backup.time.cmp(&b.backup.time));
|
||||
Ok(snapshots.last().map(|snapshot| snapshot.backup.time))
|
||||
}
|
||||
|
||||
async fn forget_target_snapshot(
|
||||
params: &PushParameters,
|
||||
target_namespace: &BackupNamespace,
|
||||
@ -635,8 +625,12 @@ pub(crate) async fn push_group(
|
||||
.unwrap_or_default();
|
||||
|
||||
let target_namespace = params.map_to_target(namespace)?;
|
||||
let last_snapshot_time = fetch_previous_backup_time(params, &target_namespace, group)
|
||||
.await?
|
||||
let mut target_snapshots = fetch_target_snapshots(params, &target_namespace, group).await?;
|
||||
target_snapshots.sort_unstable_by_key(|a| a.backup.time);
|
||||
|
||||
let last_snapshot_time = target_snapshots
|
||||
.last()
|
||||
.map(|snapshot| snapshot.backup.time)
|
||||
.unwrap_or(i64::MIN);
|
||||
|
||||
let mut source_snapshots = HashSet::new();
|
||||
@ -669,20 +663,9 @@ pub(crate) async fn push_group(
|
||||
|
||||
progress.group_snapshots = snapshots.len() as u64;
|
||||
|
||||
let target_snapshots = fetch_target_snapshots(params, &target_namespace, group).await?;
|
||||
let target_snapshots: Vec<BackupDir> = target_snapshots
|
||||
.into_iter()
|
||||
.map(|snapshot| snapshot.backup)
|
||||
.collect();
|
||||
|
||||
let mut stats = SyncStats::default();
|
||||
let mut fetch_previous_manifest = !target_snapshots.is_empty();
|
||||
for (pos, source_snapshot) in snapshots.into_iter().enumerate() {
|
||||
if target_snapshots.contains(&source_snapshot) {
|
||||
progress.done_snapshots = pos as u64 + 1;
|
||||
info!("percentage done: {progress}");
|
||||
continue;
|
||||
}
|
||||
let result =
|
||||
push_snapshot(params, namespace, &source_snapshot, fetch_previous_manifest).await;
|
||||
fetch_previous_manifest = true;
|
||||
@ -696,7 +679,6 @@ pub(crate) async fn push_group(
|
||||
}
|
||||
|
||||
if params.remove_vanished {
|
||||
let target_snapshots = fetch_target_snapshots(params, &target_namespace, group).await?;
|
||||
for snapshot in target_snapshots {
|
||||
if source_snapshots.contains(&snapshot.backup.time) {
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user