2017-02-06 79 views
1

保留目錄結構複製文件,我在我的本地計算機上的以下目錄:如何同時使用AWS命令行

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

我想要做的是所有文件複製與*.txt並保留子目錄結構到Amazon S3桶。我怎樣才能做到這一點?

在S3的一天結束。我們想找到這個文件和目錄結構:

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

使用標準的Unix命令我可以這樣做:

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

,但不知道如何與做AWS command line.

在現實中有大約10TB大小的文件傳輸。

+0

可能http://stackoverflow.com/questions/8659382/downloading-an-entire-s3-bucket – codeforester

回答

3

只需使用同步:

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

Exclude include doc

+1

的副本作爲替代'同步「(用於反覆同步),你可以使用'aws s3 cp --recursive ...'來完成同樣的工作。 –

+0

@JohnRotenstein你可以排除幷包括截至目前只與同步工作,而不是與cp或mv! –

+0

@KaranShah與'cp'一起工作您需要' - 遞歸' –