I'm trying to understand if there is a way to copy a specific version of a file to a new location e.g. normally I would do the following:
gsutil -m cp gs://my-bucket/foo-bar.py ./
But if there were 30 versions, how would I select the 29th, or any other for that matter?
Noting, I don't wish to restore the old version as a first step either.
I'm aware of the -A option to copy all, but wondering if -v can be used to get the URL first then use the standard statement above against the versioned URL?
You can use #generation
at the end of the name, as per the Using versioned objects documentation:
gsutil -m gs://my-bucket/foo-bar.py#12345 ./
Note that this is the generation number. You can use gsutil ls -a
to list the generations first:
gsutil ls -a gs://my-bucket/foo-bar.py