proxmox-backup/examples/upload-speed.rs
Christian Ebner 9072382886 api: backup: add no-cache flag to bypass local datastore cache
Adds the `no-cache` flag so the client can request to bypass the
local datastore cache for chunk uploads. This is mainly intended for
debugging and benchmarking, but can be used in cases the caching is
known to be ineffective (no possible deduplication).

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Reviewed-by: Hannes Laimer <h.laimer@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-07-22 21:43:43 +02:00

50 lines
1.2 KiB
Rust

use anyhow::Error;
use pbs_api_types::{Authid, BackupNamespace, BackupType};
use pbs_client::{BackupWriter, BackupWriterOptions, HttpClient, HttpClientOptions};
async fn upload_speed() -> Result<f64, Error> {
let host = "localhost";
let datastore = "store2";
let auth_id = Authid::root_auth_id();
let options = HttpClientOptions::default()
.interactive(true)
.ticket_cache(true);
let client = HttpClient::new(host, 8007, auth_id, options)?;
let backup_time = proxmox_time::epoch_i64();
let client = BackupWriter::start(
&client,
BackupWriterOptions {
datastore,
ns: &BackupNamespace::root(),
backup: &(BackupType::Host, "speedtest".to_string(), backup_time).into(),
crypt_config: None,
debug: false,
benchmark: true,
no_cache: false,
},
)
.await?;
println!("start upload speed test");
let res = client.upload_speedtest().await?;
Ok(res)
}
fn main() {
match proxmox_async::runtime::main(upload_speed()) {
Ok(mbs) => {
println!("average upload speed: {} MB/s", mbs);
}
Err(err) => {
eprintln!("ERROR: {}", err);
}
}
}