Copy Files to/from Google Cloud VM Instances
Quick Tip
When you are working with data in Google Cloud Platform is common that you want to send configuration files and backups to your other VM Instances or to save some information in your Cloud Storage Bucket.
Copy from one instance to other
First setup the zone you are using for your instances:
pato@patodgprmy:~$ gcloud config set compute/zone us-central1-f
Copy one file from current instance patodgprmy to remote instance patodgstby:
pato@patodgprmy:~$ gcloud compute scp $ORACLE_HOME/dbs/init.ora patodgstby:/oradata
Copy multiple files to remote instance (we use --internal-ip
to avoid charges for using external IP):
$ gcloud compute scp /oradata/respaldo/*.bkp patodgstby:/oradata/respaldo --internal-ip
depending on your IAM settings you may need to edit your instance in the Compute Engine console, setting the Cloud API access scope to Compute Engine - Read Write
Copy from/to Cloud Storage Bucket
Copy one file from your bucket to your current directory:
pato@patoracle:~$ gsutil cp gs://patobucket/oracle/tnsnames.ora .
Copy multiple files form your instance directory to your bucket:
pato@patoracle:~$ gsutil cp /oradata/respaldo/* gs://patobucket/oracle/respaldo
depending on your IAM settings you may need to edit your instance in the Compute Engine console, setting the Cloud API access scope to Storage - Full