Reputation: 59
I'm working in the deploy of some files to a Bucket in Google Cloud via Gitlab CI. The command that i'm using to remove the objects is gsutil -m rm gs://pr.homefront.com
That command removes everything from the bucket, but i would like to change it to still removing everything except a folder named "ibw" inside of that bucket every single time the command runs.
Upvotes: 0
Views: 1463
Reputation: 4640
You can add temporary holds to your objects within a folder, this holds prevent the manipulation or deletion over this objects
You can apply the holds via the following gsutil command:
gsutil -m retention temp set gs://bucketname/ibw/*******
* each asterisk is a folder level
you can set the holds before rm command and unset these after the rm command. The objects cannot be modified or removed until the hold is removed
UPDATE:
It is possible to add holds to empty folders
#this block the empty folder, if this is an folder with files all files will be blocked
gsutil -m retention temp set gs://bucketname/ibw/*******
#this operation can't remove objects,and empty folders with holds
gsutil -m rm gs://bucketname
#remove the hold of the empty folder, if this is an folder with files all files will be released
gsutil -m retention temp release gs://bucketname/ibw/*******
Upvotes: 2