[pbs-devel] [RFC v2 proxmox-backup 20/23] fix #3174: schema: add backup detection mode schema
Christian Ebner
c.ebner at proxmox.com
Mon Oct 9 13:51:36 CEST 2023
Adds the schema for switching the detection mode used to identify
regular files which changed since a reference backup run.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
Changes since version 1:
not present in version 1
pbs-api-types/src/datastore.rs | 41 ++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
index 73c4890e..723bb43d 100644
--- a/pbs-api-types/src/datastore.rs
+++ b/pbs-api-types/src/datastore.rs
@@ -65,6 +65,14 @@ pub const BACKUP_TYPE_SCHEMA: Schema = StringSchema::new("Backup type.")
]))
.schema();
+pub const BACKUP_DETECTION_MODE_SCHEMA: Schema =
+ StringSchema::new("Backup file change detection mode.")
+ .format(&ApiStringFormat::Enum(&[
+ EnumEntry::new("data", "Reading full data"),
+ EnumEntry::new("metadata", "Check file metadata"),
+ ]))
+ .schema();
+
pub const BACKUP_TIME_SCHEMA: Schema = IntegerSchema::new("Backup time (Unix epoch.)")
.minimum(1)
.schema();
@@ -1048,6 +1056,39 @@ impl std::str::FromStr for BackupPart {
}
}
+#[api]
+/// Backup file detection mode
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)]
+#[serde(rename_all = "lowercase")]
+pub enum BackupDetectionMode {
+ /// Data..
+ Data,
+ /// Metadata.
+ Metadata,
+}
+
+impl BackupDetectionMode {
+ pub const fn as_str(&self) -> &'static str {
+ match self {
+ BackupDetectionMode::Data=> "data",
+ BackupDetectionMode::Metadata => "metadata",
+ }
+ }
+}
+
+impl std::str::FromStr for BackupDetectionMode {
+ type Err = Error;
+
+ /// Parse backup file detection mode.
+ fn from_str(ty: &str) -> Result<Self, Error> {
+ Ok(match ty {
+ "data" => BackupDetectionMode::Data,
+ "metadata" => BackupDetectionMode::Metadata,
+ _ => bail!("invalid backup detection mode {ty:?}"),
+ })
+ }
+}
+
#[api(
properties: {
"backup": { type: BackupDir },
--
2.39.2
More information about the pbs-devel
mailing list