do you know if its possible to remove the retention of a bucket including any subfolder in it?
I've tried with the -m option and it includes only the objects (files) but not the subfolders and the objects inside those subfolders which is actually what I want:
gsutil -m retention event release gs://mybucket/input/*
I get the following:
Omitting prefix "gs://mybucket/input/fromkafka-05df04d2-1148-4266-857b-7bba574b2f17/_temporary/0/_temporary/attempt_20200803174938_11051_r_000000_0/". (Did you mean to do retention -r?)
Omitting prefix "gs://mybucket/input/fromkafka-05df04d2-1148-4266-857b-7bba574b2f17/_temporary/0/_temporary/attempt_20200803174938_11051_r_000000_1/". (Did you mean to do retention -r?)
Omitting prefix "gs://mybucket/input/fromkafka-05df04d2-1148-4266-857b-7bba574b2f17/_temporary/0/_temporary/attempt_20200803174938_11051_r_000000_2/". (Did you mean to do retention -r?)
Omitting prefix "gs://mybucket/input/fromkafka-05df04d2-1148-4266-857b-7bba574b2f17/_temporary/0/_temporary/attempt_20200803174938_11051_r_000000_3/". (Did you mean to do retention -r?)
Omitting prefix "gs://mybucket/input/fromkafka-05df04d2-1148-4266-857b-7bba574b2f17/_temporary/0/_temporary/attempt_20200803174938_11051_r_000001_0/". (Did you mean to do retention -r?)
Omitting prefix "gs://mybucket/input/fromkafka-05df04d2-1148-4266-857b-7bba574b2f17/_temporary/0/_temporary/attempt_20200803174938_11051_r_000001_1/". (Did you mean to do retention -r?)
Omitting prefix "gs://mybucket/input/fromkafka-05df04d2-1148-4266-857b-7bba574b2f17/_temporary/0/_temporary/attempt_20200803174938_11051_r_000001_2/". (Did you mean to do retention -r?)
Omitting prefix "gs://mybucket/input/fromkafka-05df04d2-1148-4266-857b-7bba574b2f17/_temporary/0/_temporary/attempt_20200803174938_11051_r_000001_3/". (Did you mean to do retention -r?)
And I have also tried to use that -r option but I get this:
gsutil -r retention event release gs://mybucket/*
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/utils/arg_helper.py", line 35, in GetArgumentsAndOptions
'testexceptiontraces', 'trace-token=', 'perf-trace-token='
File "/usr/lib/python3.7/getopt.py", line 95, in getopt
opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:])
File "/usr/lib/python3.7/getopt.py", line 195, in do_shorts
if short_has_arg(opt, shortopts):
File "/usr/lib/python3.7/getopt.py", line 211, in short_has_arg
raise GetoptError(_('option -%s not recognized') % opt, opt)
getopt.GetoptError: option -r not recognized
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/__main__.py", line 65, in <module>
opts, args = GetArgumentsAndOptions()
File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/utils/arg_helper.py", line 38, in GetArgumentsAndOptions
raise CommandException(e.msg)
gslib.exception.CommandException: CommandException: option -r not recognized
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/platform/gsutil/gsutil", line 21, in <module>
gsutil.RunMain()
File "/usr/lib/google-cloud-sdk/platform/gsutil/gsutil.py", line 122, in RunMain
import gslib.__main__
File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/__main__.py", line 67, in <module>
reason = e.reason if e.information else 'CommandException: %s' % e.reason
AttributeError: 'CommandException' object has no attribute 'information'
You can add as much asterisks as subfolder levels you may have, like so:
user@cs-121:~$ gsutil retention event release gs://test_bucket/****
Releasing Event-Based Hold on gs://test_bucket/folder/...
Releasing Event-Based Hold on gs://test_bucket/folder/folder2/...
Releasing Event-Based Hold on gs://test_bucket/folder/folder2/tenor.gif...
Releasing Event-Based Hold on gs://test_bucket/folder/foo.bar...
/ [4 objects]
==> NOTE: You are performing a sequence of gsutil operations that may
run significantly faster if you instead use gsutil -m retention ...
Please see the -m section under "gsutil help options" for further
information about when gsutil -m can be advantageous.
Releasing Event-Based Hold on gs://test_bucket/hello.json...
/ [5 objects]
Operation completed over 5 objects.
You can also specify a first level directory and add the asterisks after that
gsutil retention event release gs://test_bucket/folder/****