[PATCH proxmox-backup v6 05/15] client: backup writer: fix upload stats size and rate for push sync

Christian Ebner
2026-04-17T09:27:08Z

Currently, the logical size of the uploaded chunks is used for size
and upload rate calculation in case of sync jobs in push direction,
leading to inflated values for the transferred size and rate.

Use the compressed chunk size instead. To get the required
information, return the more verbose `UploadStats` on
`upload_index_chunk_info` calls and use it's compressed size for the
transferred `bytes` of `SyncStats` instead. Since `UploadStats` is
now part of a pub api, increase it's scope as well.

This is then finally being used to display the upload size and
calculate the rate for the push sync job.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
changes since version 5:
- no changes

pbs-client/src/backup_stats.rs | 20 ++++++++++----------
pbs-client/src/backup_writer.rs | 4 ++--
src/server/push.rs | 4 ++--
3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/pbs-client/src/backup_stats.rs b/pbs-client/src/backup_stats.rs
index f0563a001..edf7ef3c4 100644
--- a/pbs-client/src/backup_stats.rs
+++ b/pbs-client/src/backup_stats.rs
@@ -15,16 +15,16 @@ pub struct BackupStats {
}

/// Extended backup run statistics and archive checksum
-pub(crate) struct UploadStats {
- pub(crate) chunk_count: usize,
- pub(crate) chunk_reused: usize,
- pub(crate) chunk_injected: usize,
- pub(crate) size: usize,
- pub(crate) size_reused: usize,
- pub(crate) size_injected: usize,
- pub(crate) size_compressed: usize,
- pub(crate) duration: Duration,
- pub(crate) csum: [u8; 32],
+pub struct UploadStats {
+ pub chunk_count: usize,
+ pub chunk_reused: usize,
+ pub chunk_injected: usize,
+ pub size: usize,
+ pub size_reused: usize,
+ pub size_injected: usize,
+ pub size_compressed: usize,
+ pub duration: Duration,
+ pub csum: [u8; 32],
}

impl UploadStats {
diff --git a/pbs-client/src/backup_writer.rs b/pbs-client/src/backup_writer.rs
index 49aff3fdd..4a4391c8b 100644
--- a/pbs-client/src/backup_writer.rs
+++ b/pbs-client/src/backup_writer.rs
@@ -309,7 +309,7 @@ impl BackupWriter {
archive_name: &BackupArchiveName,
stream: impl Stream<Item = Result<MergedChunkInfo, Error>>,
options: UploadOptions,
- ) -> Result<BackupStats, Error> {
+ ) -> Result<UploadStats, Error> {
let mut param = json!({ "archive-name": archive_name });
let (prefix, archive_size) = options.index_type.to_prefix_and_size();
if let Some(size) = archive_size {
@@ -391,7 +391,7 @@ impl BackupWriter {
.post(&format!("{prefix}_close"), Some(param))
.await?;

- Ok(upload_stats.to_backup_stats())
+ Ok(upload_stats)
}

pub async fn upload_stream(
diff --git a/src/server/push.rs b/src/server/push.rs
index 697b94f2f..494e0fbce 100644
--- a/src/server/push.rs
+++ b/src/server/push.rs
@@ -1059,8 +1059,8 @@ async fn push_index(
.await?;

Ok(SyncStats {
- chunk_count: upload_stats.chunk_count as usize,
- bytes: upload_stats.size as usize,
+ chunk_count: upload_stats.chunk_count,
+ bytes: upload_stats.size_compressed,
elapsed: upload_stats.duration,
removed: None,
})
--
2.47.3