[pbs-devel] [RFC PATCH 1/4] fix #3786: api: add deep sync parameter

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Aug 2 11:19:35 CEST 2022


On June 15, 2022 10:20 am, Stefan Sterz wrote:
> allows configuring a sync job as a "deep" sync job, which will re-sync
> corrupted snapshots

I am not too happy about the naming, "deep" could mean basically 
anything, including re-syncing all missing snapshots, (re-?)syncing 
notes/verification-state/protection/..

maybe it makes sense to either make this more verbose, or already make 
it a property string "resync" with
- missing (to re-sync missing, older snapshots)
- corrupt (to re-sync corrupt snapshots)
?

> 
> Signed-off-by: Stefan Sterz <s.sterz at proxmox.com>
> ---
>  pbs-api-types/src/jobs.rs | 12 ++++++++++++
>  src/api2/config/sync.rs   | 10 ++++++++++
>  src/api2/pull.rs          | 12 ++++++++++--
>  src/server/pull.rs        |  5 +++++
>  4 files changed, 37 insertions(+), 2 deletions(-)
> 
> diff --git a/pbs-api-types/src/jobs.rs b/pbs-api-types/src/jobs.rs
> index 925a1829..87de8803 100644
> --- a/pbs-api-types/src/jobs.rs
> +++ b/pbs-api-types/src/jobs.rs
> @@ -63,6 +63,12 @@ pub const REMOVE_VANISHED_BACKUPS_SCHEMA: Schema = 
> BooleanSchema::new(
>  .default(false)
>  .schema();
>  
> +pub const DEEP_SYNC_BACKUPS_SCHEMA: Schema = BooleanSchema::new(
> +    "Checks if snapshots passed the last verification and if not 
> re-syncs them.",
> +)
> +.default(false)
> +.schema();
> +
>  #[api(
>      properties: {
>          "next-run": {
> @@ -461,6 +467,10 @@ pub const GROUP_FILTER_LIST_SCHEMA: Schema =
>              schema: NS_MAX_DEPTH_REDUCED_SCHEMA,
>              optional: true,
>          },
> +        "deep-sync":{
> +            schema: DEEP_SYNC_BACKUPS_SCHEMA,
> +            optional: true,
> +        },
>          comment: {
>              optional: true,
>              schema: SINGLE_LINE_COMMENT_SCHEMA,
> @@ -498,6 +508,8 @@ pub struct SyncJobConfig {
>      #[serde(skip_serializing_if = "Option::is_none")]
>      pub max_depth: Option<usize>,
>      #[serde(skip_serializing_if = "Option::is_none")]
> +    pub deep_sync: Option<bool>,
> +    #[serde(skip_serializing_if = "Option::is_none")]
>      pub comment: Option<String>,
>      #[serde(skip_serializing_if = "Option::is_none")]
>      pub schedule: Option<String>,
> diff --git a/src/api2/config/sync.rs b/src/api2/config/sync.rs
> index 7b9e9542..ee7f6175 100644
> --- a/src/api2/config/sync.rs
> +++ b/src/api2/config/sync.rs
> @@ -200,6 +200,8 @@ pub enum DeletableProperty {
>      schedule,
>      /// Delete the remove-vanished flag.
>      remove_vanished,
> +    /// Delete the deep-sync flag.
> +    deep_sync,
>      /// Delete the group_filter property.
>      group_filter,
>      /// Delete the rate_in property.
> @@ -286,6 +288,9 @@ pub fn update_sync_job(
>                  DeletableProperty::remove_vanished => {
>                      data.remove_vanished = None;
>                  }
> +                DeletableProperty::deep_sync => {
> +                    data.deep_sync = None;
> +                }
>                  DeletableProperty::group_filter => {
>                      data.group_filter = None;
>                  }
> @@ -381,6 +386,10 @@ pub fn update_sync_job(
>          }
>      }
>  
> +    if let Some(deep_sync) = update.deep_sync {
> +        data.deep_sync = Some(deep_sync);
> +    }
> +
>      if !check_sync_job_modify_access(&user_info, &auth_id, &data) {
>          bail!("permission check failed");
>      }
> @@ -504,6 +513,7 @@ 
> acl:1:/remote/remote1/remotestore1:write at pbs:RemoteSyncOperator
>          owner: Some(write_auth_id.clone()),
>          comment: None,
>          remove_vanished: None,
> +        deep_sync: None,
>          max_depth: None,
>          group_filter: None,
>          schedule: None,
> diff --git a/src/api2/pull.rs b/src/api2/pull.rs
> index e05e946e..424f9962 100644
> --- a/src/api2/pull.rs
> +++ b/src/api2/pull.rs
> @@ -10,8 +10,9 @@ use proxmox_sys::task_log;
>  
>  use pbs_api_types::{
>      Authid, BackupNamespace, GroupFilter, RateLimitConfig, SyncJobConfig, DATASTORE_SCHEMA,
> -    GROUP_FILTER_LIST_SCHEMA, NS_MAX_DEPTH_REDUCED_SCHEMA, PRIV_DATASTORE_BACKUP,
> -    PRIV_DATASTORE_PRUNE, PRIV_REMOTE_READ, REMOTE_ID_SCHEMA, REMOVE_VANISHED_BACKUPS_SCHEMA,
> +    DEEP_SYNC_BACKUPS_SCHEMA, GROUP_FILTER_LIST_SCHEMA, NS_MAX_DEPTH_REDUCED_SCHEMA,
> +    PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_PRUNE, PRIV_REMOTE_READ, REMOTE_ID_SCHEMA,
> +    REMOVE_VANISHED_BACKUPS_SCHEMA,
>  };
>  use pbs_config::CachedUserInfo;
>  use proxmox_rest_server::WorkerTask;
> @@ -76,6 +77,7 @@ impl TryFrom<&SyncJobConfig> for PullParameters {
>                  .clone(),
>              sync_job.remove_vanished,
>              sync_job.max_depth,
> +            sync_job.deep_sync,
>              sync_job.group_filter.clone(),
>              sync_job.limit.clone(),
>          )
> @@ -196,6 +198,10 @@ pub fn do_sync_job(
>                  schema: NS_MAX_DEPTH_REDUCED_SCHEMA,
>                  optional: true,
>              },
> +            "deep-sync": {
> +                schema: DEEP_SYNC_BACKUPS_SCHEMA,
> +                optional: true,
> +            },
>              "group-filter": {
>                  schema: GROUP_FILTER_LIST_SCHEMA,
>                  optional: true,
> @@ -224,6 +230,7 @@ async fn pull(
>      remote_ns: Option<BackupNamespace>,
>      remove_vanished: Option<bool>,
>      max_depth: Option<usize>,
> +    deep_sync: Option<bool>,
>      group_filter: Option<Vec<GroupFilter>>,
>      limit: RateLimitConfig,
>      _info: &ApiMethod,
> @@ -257,6 +264,7 @@ async fn pull(
>          auth_id.clone(),
>          remove_vanished,
>          max_depth,
> +        deep_sync,
>          group_filter,
>          limit,
>      )?;
> diff --git a/src/server/pull.rs b/src/server/pull.rs
> index b159c75d..6778c66b 100644
> --- a/src/server/pull.rs
> +++ b/src/server/pull.rs
> @@ -56,6 +56,8 @@ pub struct PullParameters {
>      remove_vanished: bool,
>      /// How many levels of sub-namespaces to pull (0 == no recursion, None == maximum recursion)
>      max_depth: Option<usize>,
> +    /// Whether to re-sync corrupted snapshots
> +    _deep_sync: bool,

nit: IMHO it's better to have this commit generate a small warning here 
instead of the churn of renaming that field in the next patch ;) but 
it's a matter of taste I guess :)

>      /// Filters for reducing the pull scope
>      group_filter: Option<Vec<GroupFilter>>,
>      /// Rate limits for all transfers from `remote`
> @@ -76,6 +78,7 @@ impl PullParameters {
>          owner: Authid,
>          remove_vanished: Option<bool>,
>          max_depth: Option<usize>,
> +        deep_sync: Option<bool>,
>          group_filter: Option<Vec<GroupFilter>>,
>          limit: RateLimitConfig,
>      ) -> Result<Self, Error> {
> @@ -90,6 +93,7 @@ impl PullParameters {
>          let remote: Remote = remote_config.lookup("remote", remote)?;
>  
>          let remove_vanished = remove_vanished.unwrap_or(false);
> +        let deep_sync = deep_sync.unwrap_or(false);
>  
>          let source = BackupRepository::new(
>              Some(remote.config.auth_id.clone()),
> @@ -107,6 +111,7 @@ impl PullParameters {
>              owner,
>              remove_vanished,
>              max_depth,
> +            _deep_sync: deep_sync,
>              group_filter,
>              limit,
>          })
> -- 
> 2.30.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 





More information about the pbs-devel mailing list