Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gsutil to list all files in a bucket that have been deleted

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.

like image 419
Luke Avatar asked Oct 23 '25 02:10

Luke


2 Answers

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.

like image 144
mhouglum Avatar answered Oct 26 '25 00:10

mhouglum


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.

like image 43
Steven Ensslen Avatar answered Oct 26 '25 02:10

Steven Ensslen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!