2

I have 4 files xxxxx.xlsx in this directory:

/var/tmp/dagxxxxx/2019-08-10/xxxxx.xlsx

I want to copy them over to:

gs://reports_dev/2019

Using gsutil cp -r the final gcs path should be like(with all 4 files):

gs://reports_dev/2019/2019-08-10/xxxxx.xlsx

I tried different combination of cp and -r like:

gsutil cp -r /var/tmp/dagxxxxx/2019-08-10/** gs://reports_dev/2019

but couldn't get the desired path in gcs.

1 Answer 1

3

Remove the trailing Asterisks, -r already means recursive, this should work:

gsutil cp -r /var/tmp/dagxxxxx/2019-08-10/ gs://reports_dev/2019

If you append a forward slash / to your source, it will copy the folder to your destination, if you don't, it will copy the Content of your source to your destination.

3
  • 2
    This is actually not working to not copy the folder to the destination, i have tried with and without the / at the end and it copies the source folder anyway.
    – Tom3652
    Commented Aug 28, 2022 at 13:28
  • 1
    @Tom3652 I think that happens because you already have content in your destination. Then it will copy the folder in your destination, so it will not overwrite what you already have there. Commented Aug 29, 2022 at 0:07
  • 1
    Yees thanks for the explanation, i have found a way stackoverflow.com/questions/73519118/… to avoid this :)
    – Tom3652
    Commented Aug 29, 2022 at 7:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.