5

I have the following directory in my local computer:

dir1
  |
  |__ randomfile.jpg
  |__ dir2
        |
        |__ file1.txt
        |__ file2.txt
        |__ pict.png

What I want to do is to copy all the files with *.txt and preserving the subdirectory structure to Amazon S3 bucket. How can I do that?

At the end of the day in S3. We'd like to find this file and directory structure:

 dir1
      |
      |__ dir2
            |
            |__ file1.txt
            |__ file2.txt

With standard Unix command I can do this:

find . -name '*.txt' -exec cp --parents \{\} /target \;

But not sure how to do with with AWS command line.

In reality with have files with ~10Tb of size to transfer.

neversaint
  • 60,904
  • 137
  • 310
  • 477

1 Answers1

8

Just use sync:

aws s3 sync src/ s3://mybucket --exclude "*" --include "*.txt"

Exclude include doc

Ôrel
  • 7,044
  • 3
  • 27
  • 46