windows 从 aws s3、cp 或同步下载文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27932345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:54:03  来源:igfitidea点击:

Downloading folders from aws s3, cp or sync?

windowsamazon-web-servicesamazon-s3

提问by BFlint

If I want to download all the contents of a directory on S3 to my local PC, which command should I use cp or sync ?

如果我想将 S3 上目录的所有内容下载到我的本地 PC,我应该使用哪个命令 cp 或 sync ?

Any help would be highly appreciated.

任何帮助将不胜感激。

For example,

例如,

if I want to download all the contents of "this folder" to my desktop, would it look like this ?

如果我想将“此文件夹”的所有内容下载到我的桌​​面,会是这样吗?

 aws s3 sync s3://"myBucket"/"this folder" C:\Users\Desktop

回答by John Rotenstein

Using aws s3 cpfrom the AWS Command-Line Interface (CLI)will require the --recursiveparameter to copy multiple files.

使用aws s3 cpAWS命令行界面(CLI)将要求--recursive参数来复制多个文件。

aws s3 cp s3://myBucket/dir localdir --recursive

The aws s3 synccommand will, by default, copy a whole directory. It will only copy new/modified files.

aws s3 sync默认情况下,该命令将复制整个目录。它只会复制新的/修改过的文件。

aws s3 sync s3://mybucket/dir localdir

Just experiment to get the result you want.

只需尝试即可获得您想要的结果。

Documentation:

文档:

回答by myPavi

In case you need to use another profile, especially cross account. you need to add the profile in the config file

如果您需要使用其他配置文件,尤其是跨帐户。您需要在配置文件中添加配置文件

[profile profileName]
region = us-east-1
role_arn = arn:aws:iam::XXX:role/XXXX
source_profile = default

and then if you are accessing only a single file

然后如果你只访问一个文件

aws s3 cp s3://crossAccountBucket/dir localdir --profile profileName


回答by gCoh

In the case you want to download a single file, you can try the following command:

如果您想下载单个文件,可以尝试以下命令:

aws s3 cp s3://bucket/filename /path/to/dest/folder

回答by Marc Duby

Just used version 2 of the AWS CLI. For the s3 option, there is also a --dryrun option now to show you what will happen:

刚刚使用了 AWS CLI 的第 2 版。对于 s3 选项,现在还有一个 --dryrun 选项来显示会发生什么:

aws s3 --dryrun cp s3://bucket/filename /path/to/dest/folder --recursive

aws s3 --dryrun cp s3://bucket/filename /path/to/dest/folder --recursive