From: Stefan Sterz <s.sterz@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [RFC PATCH 1/4] fix #3786: api: add deep sync parameter
Date: Wed, 15 Jun 2022 10:20:37 +0200 [thread overview]
Message-ID: <20220615082040.96959-2-s.sterz@proxmox.com> (raw)
In-Reply-To: <20220615082040.96959-1-s.sterz@proxmox.com>
allows configuring a sync job as a "deep" sync job, which will re-sync
corrupted snapshots
Signed-off-by: Stefan Sterz <s.sterz@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@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,
/// 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
next prev parent reply other threads:[~2022-06-15 8:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 8:20 [pbs-devel] [RFC PATCH 0/4] fix #3786: add a "deep sync" option to sync jobs Stefan Sterz
2022-06-15 8:20 ` Stefan Sterz [this message]
2022-08-02 9:19 ` [pbs-devel] [RFC PATCH 1/4] fix #3786: api: add deep sync parameter Fabian Grünbichler
2022-06-15 8:20 ` [pbs-devel] [RFC PATCH 2/4] fix #3786: server/datastore: add deep sync parameter to pull sync jobs Stefan Sterz
2022-08-02 10:07 ` Fabian Grünbichler
2022-06-15 8:20 ` [pbs-devel] [RFC PATCH 3/4] fix #3786: ui/cli: add deep sync option to ui and cli Stefan Sterz
2022-06-15 8:20 ` [pbs-devel] [RFC PATCH 4/4] fix #3786: docs: document deep sync behavior and prerequisites Stefan Sterz
2022-06-22 10:52 ` [pbs-devel] [RFC PATCH 0/4] fix #3786: add a "deep sync" option to sync jobs Matthias Heiserer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220615082040.96959-2-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox