From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v2 7/8] datastore: delete all objects on datastore destroy with remove data
Date: Wed, 30 Jul 2025 09:57:49 +0200 [thread overview]
Message-ID: <20250730075750.36014-8-c.ebner@proxmox.com> (raw)
In-Reply-To: <20250730075750.36014-1-c.ebner@proxmox.com>
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@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@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
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2025-07-30 7:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 7:57 [pbs-devel] [PATCH proxmox-backup v2 0/8] remove objects from s3 backend on datastore destroy Christian Ebner
2025-07-30 7:57 ` [pbs-devel] [PATCH proxmox-backup v2 1/8] tree wide: fix useless borrow warnings Christian Ebner
2025-07-30 7:57 ` [pbs-devel] [PATCH proxmox-backup v2 2/8] client: backup writer: elide lifetime which can be auto inferred Christian Ebner
2025-07-30 7:57 ` [pbs-devel] [PATCH proxmox-backup v2 3/8] api: tape: fix clippy warning on map iteration Christian Ebner
2025-07-30 7:57 ` [pbs-devel] [PATCH proxmox-backup v2 4/8] datastore: fix clippy warning checking file extension Christian Ebner
2025-07-30 7:57 ` [pbs-devel] [PATCH proxmox-backup v2 5/8] datastore: fix clippy warning to use ? on option Christian Ebner
2025-07-30 7:57 ` [pbs-devel] [PATCH proxmox-backup v2 6/8] datastore: add helper to get s3 client from datastore config Christian Ebner
2025-07-30 7:57 ` Christian Ebner [this message]
2025-07-30 7:57 ` [pbs-devel] [PATCH proxmox-backup v2 8/8] ui: switch datastore destroy label text on backend type Christian Ebner
2025-07-30 14:51 ` [pbs-devel] applied-series: [PATCH proxmox-backup v2 0/8] remove objects from s3 backend on datastore destroy Thomas Lamprecht
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=20250730075750.36014-8-c.ebner@proxmox.com \
--to=c.ebner@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