Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to copy a directory from a Google Compute Engine instance to my local machine?

Tags:

With scp I can add the -r flag to download directories to my local machine via ssh.

When using:

gcloud compute scp -r 

it sais that '-r' is not an available option. Without -r I get an error saying that my source path is a directory. (Implying I can only download single files.)

Is there an equivalent to -r flag for gcloud compute scp command?

like image 703
ThatBrianDude Avatar asked Sep 21 '17 10:09

ThatBrianDude


People also ask

How do I transfer from cloud to local?

You can copy files from the remote system to the local system using the gcloud command. To denote a file in Cloud Shell, prefix the file name with the string "cloudshell". To denote a local file, prefix the file name with the string "localhost" as shown below.


1 Answers

Found it!

GCE offers an equivalent and it is --recurse.

My final command looks like this:

gcloud compute scp --recurse username@instance_name:./* "local_dir"

For some reason I also needed the * behind the source folder to avoid some security issue.

like image 142
ThatBrianDude Avatar answered Oct 16 '22 04:10

ThatBrianDude