Copying data between buckets using the gsutil command line

When gsutil, we once again treat the buckets as source and destination directories:

  1. Use the gsutil cp command as follows to upload file(s) to the bucket. Note that the command needs both source and destination URLs:
gsutil cp <Source> <Destination>    

For instance:

gsutil cp gs://loonycorn-bucket-00/image1.png  gs://loonycorn-      
bucket-01
  1. Do not forget to add a file extension or the file shall not upload
  2. Later, you can use the ls command to verify your upload
  3. Similarly, the gsutil mv command can be used to move data from one bucket to another:
gsutil mv gs://loonycorn-bucket-00/image1.png gs://loonycorn-bucket-01
  1. While moving data from one bucket to another, the permission of the buckets may be different. We can make a choice between whether we want the moved objects to maintain their previous bucket's permission or whether we want them to inherit the new bucket's permission. Providing -p as the argument allows us to maintain the permissions from a previous bucket and the same logic applies to copying data as well:
gsutil mv -p gs://loonycorn-bucket-00/image1.png gs://loonycorn-bucket-01  
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset