6 Ways to Transfer Files in Google Cloud Platform. In this guide you are going to learn different steps to transfer files in Google Cloud.
Prequisites
Install and Setup Google Cloud SDK.
To use the gsutil
command you need a little knowledge about how to use the terminal/command line/ssh.
Set up Google Cloud SDK
Once you have installed Google Cloud SDK you can use gsutil
gcloud
Open terminal in your local computer and configure the project you wish to use. Run the following command to set up gcloud
gcloud init
Google Cloud Storage to Google Compute Engine
To copy a file from Google Cloud Storage to your VM Instance use the following command.
You can run this command either by the local terminal or from VM Instance SSH.
gsutil cp gs://bucket_name/filename /home/username/folder_name
This command syncs the file from Cloud Storage to your VM Instance.
Google Compute Engine to Google Cloud Storage
To copy a file from your VM Instance to Cloud Storage, SSH your VM Instance and navigate to the directory where the file is and execute the following command.
gsutil cp filename gs://bucket_name
This command syncs the file from your Instance to your Storage Bucket.
Google Cloud Storage to Local Computer
Open terminal in your local computer and navigate to the folder where you need the file to be copied and run this command.
gsutil -m cp -r gs://bucket_name/folder dir
This will cause everything nested under gs://bucket_name/folder
to be downloaded into dir
, resulting in files with names like dir/data/a/b/c
Local Computer to Google Cloud Storage
Open a terminal in your local computer and navigate to the folder where the file is and run this command.
gsutil -m cp -r dir gs://bucket_name/folder
This will cause everything nested under dir
to be downloaded into gs://bucket_name/folder
Upload/Download using SSH
To download or upload a file using SSH click the SSH button next to your VM Instance to open a terminal in your web browser.
Click the top right gear icon in your terminal window to upload or download a file directly. This method will be very slow compared to the above all process.
From one Instance to Another Instance
You can also transfer files from one instance to another instance using the gcloud
command.
gcloud compute scp FILE_NAME --project TARGET_PROJECT_ID TARGET_INSTANCE_NAME:folder_name --zone region
Another method is below.
gcloud compute copy-files instance_name:remote_location local_dir --zone=region
Transfer files using FileZilla
You can setup SFTP to fransfer files using FileZilla.
Get your Professional Google Cloud Architect certificate with this easy to learn course now.
These are the different methods to transfer files in Google Cloud Platform.
Leave your Reply