Google Cloud Tools for PowerShell Copy-GcsObject 返回多区域存储桶错误

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

我正在尝试使用 cmdlet Copy-GcsObject 来备份一些文件,但失败了。

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"

当我尝试将文件对象从区域存储桶复制到多区域存储桶时返回以下错误。有什么解决办法吗?

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

如果我复制到同一区域的另一个区域存储桶,它工作正常。

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,这是基于不同的位置。

当您对具有区域存储 class 的两个存储桶执行相同的操作时,它会起作用,因为它们具有相同的存储桶。

解决方案是遵循@Adam 的建议和运行 gsutil cp 命令在存储桶之间复制文件。首先,您可以通过以下方式访问 Cloud Storage PowerShell Provider:

cd gs:\

然后使用此命令在存储桶之间复制您的文件,而不管存储 class:

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