将文件从远程服务器复制到谷歌云存储桶 [英] Copy files from remote server to google cloud bucket
问题描述
如何将文件从远程服务器复制到 Google 存储桶?例如,
How would I copy files from a remote server to a google bucket? For example,
gcloud compute scp username@server:/path/to/file gs://my-bucket
此方法报错:当目标为远程时,所有源必须是本地文件.
另外,gsutil 只支持 cp 而不是 scp.
Additionally, gsutil only provides support for cp and not scp.
提前致谢!
推荐答案
您也可以直接在您的 GCE VM 上执行 gsutil
命令(大多数 VM 镜像都预装了 Cloud SDK).例如:
You can also directly execute gsutil
command on your GCE VM (Most VM images have Cloud SDK preinstalled). For example:
gcloud compute ssh user@server --zone my_zone
--command='gsutil cp path/to/my_file gs://MY_BUCKET'
请注意,要使其正常工作,与 VM 关联的服务帐户必须具有对 GCS 的适当访问范围.如果你跑
Note that for this to work your service account associated with VM must have appropriate access scope to GCS. If you run
gcloud beta compute instances describe my_instance --zone my_zone
--format="value(serviceAccounts.scopes)"
它将显示为 VM 服务帐户设置的范围列表.确保您有 https://www.googleapis.com/auth/cloud-platform
或 https://www.googleapis.com/auth/devstorage.full_control
或https://www.googleapis.com/auth/devstorage.read_write
.如果没有,您可以使用set-scopes beta 命令 重置它们或转到控制台并编辑有问题的虚拟机.
It will show list of scopes set for VM service account. Make sure you have https://www.googleapis.com/auth/cloud-platform
or https://www.googleapis.com/auth/devstorage.full_control
or https://www.googleapis.com/auth/devstorage.read_write
. If not you can use
set-scopes beta command to reset them or go to console and edit VM in question.
这篇关于将文件从远程服务器复制到谷歌云存储桶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!