DESCRIPTION
gcloud compute copy-files
copies files between a virtual machine instance
and your local machine.
To denote a remote file, prefix the file name with the virtual
machine instance name (e.g., example-instance
:/FILE). To
denote a local file, do not add a prefix to the file name
(e.g., /FILE
). For example, to copy a remote directory
to your local host, run:
$ gcloud compute copy-files example-instance:~/REMOTE-DIR ~/LOCAL-DIR \
--zone us-central1-a
In the above example, ~/REMOTE-DIR
from example-instance
is
copied into the ~/LOCAL-DIR
directory.
Conversely, files from your local computer can be copied to a
virtual machine:
$ gcloud compute copy-files ~/LOCAL-FILE-1 ~/LOCAL-FILE-2 \
example-instance:~/REMOTE-DIR --zone us-central1-a
If a file contains a colon (:
), you must specify it by
either using an absolute path or a path that begins with
./
.
Under the covers, scp(1)
is used to facilitate the transfer.
When the destination is local, all sources must be the same
virtual machine instance. When the destination is remote, all
source must be local.