diff --git a/pbs-api-types/src/jobs.rs b/pbs-api-types/src/jobs.rs index 46ae4fe2..87009b3a 100644 --- a/pbs-api-types/src/jobs.rs +++ b/pbs-api-types/src/jobs.rs @@ -186,6 +186,10 @@ pub const VERIFICATION_OUTDATED_AFTER_SCHEMA: Schema = optional: true, schema: BACKUP_NAMESPACE_SCHEMA, }, + "max-depth": { + optional: true, + schema: crate::NS_MAX_DEPTH_SCHEMA, + }, } )] #[derive(Serialize, Deserialize, Updater)] @@ -212,6 +216,10 @@ pub struct VerificationJobConfig { #[serde(skip_serializing_if = "Option::is_none", default)] /// on which backup namespace to run the verification recursively pub ns: Option, + #[serde(skip_serializing_if = "Option::is_none", default)] + /// how deep the verify should go from the `ns` level downwards. Passing 0 verifies only the + /// snapshots on the same level as the passed `ns`, or the datastore root if none. + pub max_depth: Option, } #[api( diff --git a/src/api2/config/verify.rs b/src/api2/config/verify.rs index dc188300..b7d1ffd4 100644 --- a/src/api2/config/verify.rs +++ b/src/api2/config/verify.rs @@ -157,6 +157,8 @@ pub enum DeletableProperty { OutdatedAfter, /// Delete namespace property, defaulting to root namespace then. Ns, + /// Delete max-depth property, defaulting to full recursion again + MaxDepth, } #[api( @@ -239,6 +241,9 @@ pub fn update_verification_job( DeletableProperty::Ns => { data.ns = None; } + DeletableProperty::MaxDepth => { + data.max_depth = None; + } } } } @@ -278,6 +283,11 @@ pub fn update_verification_job( data.ns = Some(ns); } } + if let Some(max_depth) = update.max_depth { + if max_depth <= pbs_api_types::MAX_NAMESPACE_DEPTH { + data.max_depth = Some(max_depth); + } + } config.set_data(&id, "verification", &data)?; diff --git a/src/server/verify_job.rs b/src/server/verify_job.rs index cf3e154f..a861cd31 100644 --- a/src/server/verify_job.rs +++ b/src/server/verify_job.rs @@ -50,7 +50,7 @@ pub fn do_verification_job( &verify_worker, worker.upid(), ns, - None, + verification_job.max_depth, None, Some(&move |manifest| { verify_filter(ignore_verified_snapshots, outdated_after, manifest)