Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'aws s3 sync' only copy files with a certain extension

I have an S3 bucket from which I would like to copy:

  1. The entire directory structure (all directories and child directories, at any length)
  2. Wherever they are in the directory structure, all files that match a certain file-name path (Eg: *.log, *070719*.csv, etc.)

Is there any way to do this from the AWS CLI?

like image 630
MrD Avatar asked Oct 23 '25 15:10

MrD


1 Answers

Yes, you can.

Take a look at AWS CLI documentation: Use of Exclude and Include Filters:

Currently, there is no support for the use of UNIX style wildcards in a command's path arguments. However, most commands have --exclude "<value>" and --include "<value>" parameters that can achieve the desired result. These parameters perform pattern matching to either exclude or include a particular file or object.

For example, if the filter parameters passed to the command were:

--exclude "*" --include "*.txt"

All files will be excluded from the command except for files ending with .txt.

like image 76
mostaszewski Avatar answered Oct 25 '25 07:10

mostaszewski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!