如何说服 AWS CLI 同步排除与目录模式匹配的任何文件?



用例是我想排除某些数据进入 S3。这些文件可以位于文件层次结构中的任何位置,但如果它们包含在名为foobar的目录下的任何位置,我不希望将它们复制过来。

例如:

/my-data/20150806-1600/foobar/blah.csv  # Exclude
/my-data/20150806-1600/dingbat/blah.csv # Include
/my-data/clients/foobar/README.txt      # Exclude
$ /usr/local/bin/aws --version
aws-cli/1.11.117 Python/2.7.6 Linux/3.13.0-92-generic botocore/1.5.80

唉。。。

/usr/local/bin/aws s3 sync /my-data/ s3://my-bucket/my-data/ --exclude '*/foobar/*' --exclude '*/foobaz/*' --delete

文件仍会上传。我尝试将排除模式更改为foobar/**foobar*但在每种情况下,与路径中foobar的父目录匹配的文件仍然会被上传。

对我来说,它似乎只能通过排除*foobar**foorbar/*来工作。排除*/foobar/*不起作用:

$ ls -lR stack
total 8
drwxr-xr-x  3 user  wheel  102  8 Jul 23:25 foobar
-rw-r--r--  1 user  wheel    5  8 Jul 23:25 level1
stack/foobar:
total 8
-rw-r--r--  1 user  wheel  5  8 Jul 23:25 level2
$ aws s3 sync stack/ s3://my-bucket --exclude '*foobar*'
upload: stack/level1 to s3://my-bucket/level1

相关内容

最新更新