From f971b8c1e6b853a36df669c452e28c6ef5c7cf4d Mon Sep 17 00:00:00 2001 From: Stefan Hanreich Date: Tue, 18 Apr 2023 16:59:45 +0200 Subject: [PATCH] partial fix #3701: sync job: pull: add transfer-last parameter Specifying the transfer-last parameter limits the amount of backups that get synced via the pull command/sync job. The parameter specifies how many of the N latest backups should get pulled/synced. All other backups will get skipped. This is particularly useful in situations where the sync target has less disk space than the source. Syncing all backups from the source is not possible if there is not enough disk space on the target. Additionally this can be used for limiting the amount of data transferred, reducing load on the network. The newest backup will always get re-synced, regardless of the setting of the transfer-last parameter. Signed-off-by: Stefan Hanreich --- pbs-api-types/src/jobs.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pbs-api-types/src/jobs.rs b/pbs-api-types/src/jobs.rs index cf7618c4..23e19b7b 100644 --- a/pbs-api-types/src/jobs.rs +++ b/pbs-api-types/src/jobs.rs @@ -444,6 +444,11 @@ pub const GROUP_FILTER_SCHEMA: Schema = StringSchema::new( pub const GROUP_FILTER_LIST_SCHEMA: Schema = ArraySchema::new("List of group filters.", &GROUP_FILTER_SCHEMA).schema(); +pub const TRANSFER_LAST_SCHEMA: Schema = + IntegerSchema::new("Limit transfer to last N snapshots (per group), skipping others") + .minimum(1) + .schema(); + #[api( properties: { id: { @@ -493,6 +498,10 @@ pub const GROUP_FILTER_LIST_SCHEMA: Schema = schema: GROUP_FILTER_LIST_SCHEMA, optional: true, }, + "transfer-last": { + schema: TRANSFER_LAST_SCHEMA, + optional: true, + }, } )] #[derive(Serialize, Deserialize, Clone, Updater, PartialEq)] @@ -522,6 +531,8 @@ pub struct SyncJobConfig { pub group_filter: Option>, #[serde(flatten)] pub limit: RateLimitConfig, + #[serde(skip_serializing_if = "Option::is_none")] + pub transfer_last: Option, } impl SyncJobConfig {