Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gsutil cp command copies entire directory path (on Windows) - bug?

I am having a problem where gsutil does not seem to follow the behavior described in the documentation (at least in Windows). The documentation states:


When performing recursive directory copies, object names are constructed that mirror the source directory structure starting at the point of recursive processing. For example, the command:

gsutil cp -R dir1/dir2 gs://my_bucket

will create objects named like gs://my_bucket/dir2/a/b/c, assuming dir1/dir2 contains the file a/b/c.


However, in practice I have found that it will create objects named:

gs://my_bucket/dir1/dir2/a/b/c

ie, it copies the entire directory path stated in the gsutil command, rather than "starting at the point of recursive processing" (dir2) as stated in the documentation.

Am I missing/misunderstanding something here?

like image 698
user3610488 Avatar asked Jun 05 '14 17:06

user3610488


People also ask

What does gsutil CP do?

The gsutil cp command attempts to name objects in ways that are consistent with the Linux cp command. This means that names are constructed depending on whether you're performing a recursive directory copy or copying individually-named objects, or whether you're copying to an existing or non-existent directory.

Does gsutil CP create folder?

You cannot create a folder with gsutil on GCS. But you can copy an existing folder with gsutil to GCS.

What does gsutil rsync do?

The gsutil rsync command copies changed files in their entirety and does not employ the rsync delta-transfer algorithm to transfer portions of a changed file. This is because Cloud Storage objects are immutable and no facility exists to read partial object checksums or perform partial replacements.


1 Answers

I noticed the same behavior when using the gsutil cp -R command with a similar directory structure. In order to copy the desired directory from within the 'dir2' level I used the command: gsutil rsync -r dir1/dir2 gs://mybucket

like image 195
JoshFire311 Avatar answered Sep 20 '22 07:09

JoshFire311