[pbs-devel] [PATCH proxmox-backup v5 26/46] datastore: create namespace marker in s3 backend

Christian Ebner c.ebner at proxmox.com
Thu Jul 3 15:18:17 CEST 2025


The S3 object store only allows to store objects, referenced by their
key. For backup namespaces datastores however use directories, so
they cannot be represented as one to one mapping.

Instead, create an empty marker file for each namespace and operate
based on that.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 pbs-datastore/src/datastore.rs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 3e54ce31f..89e85dbea 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -43,6 +43,7 @@ static DATASTORE_MAP: LazyLock<Mutex<HashMap<String, Arc<DataStoreImpl>>>> =
     LazyLock::new(|| Mutex::new(HashMap::new()));
 
 const GROUP_NOTES_FILE_NAME: &str = "notes";
+const NAMESPACE_MARKER_FILENAME: &str = ".namespace";
 
 /// checks if auth_id is owner, or, if owner is a token, if
 /// auth_id is the user of the token
@@ -608,6 +609,20 @@ impl DataStore {
         // construct ns before mkdir to enforce max-depth and name validity
         let ns = BackupNamespace::from_parent_ns(parent, name)?;
 
+        if let DatastoreBackend::S3(s3_client) = self.backend()? {
+            let marker = ns.path().join(NAMESPACE_MARKER_FILENAME);
+            let namespace_marker = marker
+                .to_str()
+                .ok_or_else(|| format_err!("unexpected namespace path"))?;
+
+            let _is_duplicate = proxmox_async::runtime::block_on(s3_client.upload_with_retry(
+                namespace_marker.into(),
+                hyper::body::Bytes::from(""),
+                false,
+            ))
+            .context("failed to create namespace on s3 backend")?;
+        }
+
         let mut ns_full_path = self.base_path();
         ns_full_path.push(ns.path());
 
-- 
2.47.2





More information about the pbs-devel mailing list