Copy files from remote server to Google Cloud Cloud
How to copy files from remote server to google bucket? For example,
gcloud compute scp username@server:/path/to/file gs://my-bucket
This method gives an error: All sources must be local files when destination is remote.
Also, gsutil only provides support for cp, not scp.
Thanks in advance!
source to share
You can also directly execute the command gsutil
on your GCE VM (most VM images have the cloud SDK pre-installed). For example:
gcloud compute ssh user@server --zone my_zone \
--command='gsutil cp path/to/my_file gs://MY_BUCKET'
Note that for this to work, your service account associated with the VM must have an appropriate scope for GCS. If you run
gcloud beta compute instances describe my_instance --zone my_zone \
--format="value(serviceAccounts.scopes)"
It will display a list of scopes set for the VM service account. Make sure you have https://www.googleapis.com/auth/cloud-platform
either https://www.googleapis.com/auth/devstorage.full_control
or https://www.googleapis.com/auth/devstorage.read_write
. If not, you can use
the set-scopes beta command to reset, or go to the console and edit the VM.
source to share