将文件从远程服务器复制到Google Cloud Bucket [英] 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
此方法给出错误:All sources must be local files when destination is remote.
另外,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命令以将其重置或进入控制台并编辑有问题的VM.
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.
这篇关于将文件从远程服务器复制到Google Cloud Bucket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!