How do you list all objects in a bucket that have been deleted when object versioning has been enabled? I'd like to use gsutil for this if possible.
Edit: It seems like there is no built in tool to do this. Could there perhaps be a way to do it via some combination of gsutil and another bash tool?
When you have a large amount of files, listing all versions is too much information and obscures what one might be looking for: do I have any deleted files and should I permanently delete them or restore them.
Running gsutil help ls shows that the -a flag will do this:
-a Includes non-current object versions / generations in the listing
(only useful with a versioning-enabled bucket). If combined with
-l option also prints metageneration for each listed object.
Note that this will show objects that were deleted while versioning was enabled. If an object is deleted when versioning is not turned on, it is permanently deleted.
Since November 2023 (GCloud 454.0.0), gcloud storage ls gs://path --soft-deleted shows the soft-deleted blobs.
The fully deleted blobs are gone, as is their metadata.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With