2

A current project directory on Mac machine, having some files and directories, needs to be copied over to aws s3 bucket but without some directories some of which are hidden.
I could not figure out from the docs how to do that, thus my guess is:

aws> s3 cp . s3://bucketName --recursive --exclude "how to put the list of directories to exclude here"?

Thanks

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Fred J.
  • 5,759
  • 10
  • 57
  • 106

2 Answers2

4

Amazon S3 doesn't really support directories. Rather, the name of directory (the "path") is pre-pended onto the name of the file.

So, imagine this structure:

docs
  + foo
  + bar
  + foobar

If you wish to copy then whole docs directory, but skip the bar directory, use this command from within the docs directory:

aws s3 cp . s3://mybucket --recursive --exclude 'bar/*'

This tells it to copy all files, except those that begin with bar/.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
1

From s3's Use of Filters:

Any number of these parameters can be passed to a command. You can do this by providing an --exclude or --include argument multiple times, e.g. --include ".txt" --include ".png". When there are multiple filters, the rule is the filters that appear later in the command take precedence over filters that appear earlier in the command.

So, just give the command an --exclude option for each directory you want to skip.

jzonthemtn
  • 3,344
  • 1
  • 21
  • 30