Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy file to local google storage via command line (like gsutil cp)

To emulate production, I want to copy a file to my local google storage (app_default_bucket) maintained by the app engine launcher. This is performed via 'gsutil cp' in production. I would like to do the same locally. Possible?

I would like to avoid writing an app just for local use.

like image 744
Mendolis Avatar asked Sep 30 '22 08:09

Mendolis


People also ask

What is gsutil cp command?

The gsutil cp command allows you to copy data between your local file system and the cloud, within the cloud, and between cloud storage providers. For example, to upload all text files from the local directory to a bucket, you can run: gsutil cp *.txt gs://my-bucket. You can also download data from a bucket.

What is the command to move a file from one Cloud Storage bucket to another?

Which command would you use to move objects between two cloud storage buckets? To copy any single object from one GCS location to another, you can use the copy command. This can be done from either of our public APIs, or by using the command-line client, gsutil.

Which tool has commands such as MB and cp to perform operations?

The gsutil tool has commands such as mb and cp to perform operations.


1 Answers

Since GCS local storage (localhost:8000/_ah/gcs/app_default_bucket) is mapped to /tmp/storage directory (at least on Linux) and cp command supports directory destination, copying files from a bucket to local storage is just a matter of:

gsutil -m cp -r gs://[my-bucket] /tmp/storage
like image 129
Stan Bashtavenko Avatar answered Dec 31 '22 22:12

Stan Bashtavenko