Google Cloud Tools for PowerShell Copy-GcsObject returning error with multi-regional bucket

968 views Asked by At

I am trying to use the the cmdlet Copy-GcsObject to backup some files but its failing.

Copy-GcsObject -SourceBucket "my-bucket" -SourceObjectName "Drivers/storage/PFJ82/Drivers/Production/Windows10-x64/iaStorAC.inf/iaStorF.sys" -DestinationObjectName  "Drivers/storage/PFJ82/Drivers/Production/Windows10-x64/iaStorAC.inf/iaStorF.sys" -DestinationBucket "central-backup"

It is returning the following error when I try to copy a file object from a Regional bucket to a Multi-Regional bucket. Is there any way around this?

Copy-GcsObject : Google.Apis.Requests.RequestError
The combination of locationConstraint and storageClass you provided is not supported for your project [400]
Errors [
    Message[The combination of locationConstraint and storageClass you provided is not supported for your project] Location[ - ] Reason[invalid] 
Domain[global]
]
At line:1 char:1
+ Copy-GcsObject -SourceBucket "dr-db-bucket" -SourceObjectName "Driver ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-GcsObject], GoogleApiException
    + FullyQualifiedErrorId : Google.GoogleApiException,Google.PowerShell.CloudStorage.CopyGcsObject

It works fine if I copy to another Regional bucket in the same region.

1

There are 1 answers

0
Rodrigo C. On BEST ANSWER

The error you are getting comes from your buckets being on different storage classes, as you indicated. With one bucket on a Regional storage class and the other on a Multi-Regional storage class, the copy operation fails because of the difference in storage classes, which are based on different locations.

When you perform the same operation with two buckets that have the Regional storage class, it works because they have the same one.

The solution for this would be to follow @Adam's advice and run the gsutil cp command to copy your files between buckets. First, you can access the Cloud Storage PowerShell Provider with this:

cd gs:\

And then use this command to copy your files between buckets, regardless of storage class:

gsutil cp gs://[BUCKET_A/YOUR_FILE] gs://[BUCKET_B]