[pbs-devel] [PATCH proxmox-backup v2 7/8] datastore: delete all objects on datastore destroy with remove data

Christian Ebner c.ebner at proxmox.com
Wed Jul 30 09:57:49 CEST 2025


If the user requested to delete a datastore, including all of the data,
also remove the objects from the s3 backend, if any.

This is limited to deleting objects within the datastore path prefix
within the bucket.

Reported-by: Lukas Wagner <l.wagner at proxmox.com>
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner at proxmox.com>
Tested-by: Lukas Wagner <l.wagner at proxmox.com>
---
changes since version 1:
 - no changes

 pbs-datastore/src/datastore.rs | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 3bc3aab0d..3e53a670b 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -2144,6 +2144,18 @@ impl DataStore {
                 }
             }
 
+            if let (_backend, Some(s3_client)) =
+                Self::s3_client_and_backend_from_datastore_config(&datastore_config)?
+            {
+                // Delete all objects within the datastore prefix
+                let prefix = S3PathPrefix::Some(String::default());
+                let delete_objects_error =
+                    proxmox_async::runtime::block_on(s3_client.delete_objects_by_prefix(&prefix))?;
+                if delete_objects_error {
+                    bail!("deleting objects failed");
+                }
+            }
+
             // chunks get removed last and only if the backups were successfully deleted
             if ok {
                 remove(".chunks", &mut ok);
-- 
2.47.2





More information about the pbs-devel mailing list