Скопируйте файлы из экземпляра Google Compute Engine в корзину Google Cloud Storage.

3977
sathishvj

Есть ли способ скопировать файлы из экземпляра Google Compute Engine непосредственно в корзину Google Cloud Storage? Похоже, что нет никакой информации на gcloud compute copy-filesстранице справки или в документации Google Cloud Storage.

Единственные примеры, которые я вижу, это загрузить их локально, а затем снова загрузить, что не имеет смысла для меня, если есть очень большие файлы.

2

1 ответ на вопрос

4
chrispomeroy

The best way to do this is to SSH into the instance and use the gsutil command to copy files directly from the GCE instance to a GCS bucket.

Keep in mind the instance needs to have Google Cloud Storage "write scope" which is a setting you need to create when you first create the instance OR you can add later using a service account.

If you're using a machine image that was provided by Google, gsutil is already installed on the VM instance.

Example:

gsutil cp file1 file2 gs://bucket 

If you have a lot of files to upload, you can parallelize via -m:

gsutil -m cp file1 file2 gs://bucket 

If you want to recursively upload a directory, use -r:

gsutil cp -r dir1 gs://bucket 

See the docs for gsutil cp for more information.

Похожие вопросы