我注意到似乎没有从AWS管理控制台下载整个s3桶的选项。

有什么简单的方法可以把所有东西都装进我的桶里吗?我正在考虑使根文件夹公共,使用wget抓取它,然后再次使它私有,但我不知道是否有更简单的方法。


当前回答

你可以用s3cmd命令简单地得到它:

s3cmd get --recursive --continue s3://test-bucket local-directory/

其他回答

AWS CLI是在本地下载整个S3存储桶的最佳选择。

安装AWS CLI。 配置AWS CLI以使用默认的安全凭据和默认的AWS区域。 下载整个S3桶使用命令 Aws s3 sync s3://yourbucketname localpath

不同AWS服务的AWS CLI参考:AWS命令行接口

您有许多选项可以做到这一点,但最好的是使用AWS CLI。

下面是一篇简介:

Download and install AWS CLI in your machine: Install the AWS CLI using the MSI Installer (Windows). Install the AWS CLI using the Bundled Installer for Linux, OS X, or Unix. Configure AWS CLI: Make sure you input valid access and secret keys, which you received when you created the account. Sync the S3 bucket using: aws s3 sync s3://yourbucket /local/path In the above command, replace the following fields: yourbucket >> your S3 bucket that you want to download. /local/path >> path in your local system where you want to download all the files.

您可以使用这个AWS cli命令将整个S3桶内容下载到本地文件夹

aws s3 sync s3://your-bucket-name "Local Folder Path"

如果你看到这样的错误

fatal error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)

——no-verify-ssl(布尔)

默认情况下,AWS CLI与AWS服务通信时使用SSL。对于每个SSL连接,AWS CLI将验证SSL证书。此选项将覆盖验证SSL证书的默认行为。 参考

使用命令——no-verify-ssl来使用这个标记

aws s3 sync s3://your-bucket-name "Local Folder Path" --no-verify-ssl

正如Neel Bhaat在这篇博客中解释的那样,有许多不同的工具可以用于此目的。有些是AWS提供的,大多数是第三方工具。所有这些工具都要求您将AWS帐户密钥和秘密保存在工具本身。在使用第三方工具时要非常谨慎,因为你保存的凭证可能会让你失去全部价值,让你完蛋。

因此,我总是建议为此使用AWS CLI。您可以从这个链接简单地安装它。接下来,运行以下命令并在AWS CLI中保存密钥和秘密值。

aws configure

并使用以下命令将AWS S3 Bucket同步到本地计算机。(本地机器应该安装了AWS CLI)

aws s3 sync <source> <destination>

例子:

1)用于AWS S3到本地存储

aws s3 sync <S3Uri> <LocalPath>

2)从本地存储到AWS S3

aws s3 sync <LocalPath> <S3Uri>

3)从AWS s3桶到另一个桶

aws s3 sync <S3Uri> <S3Uri> 

试试这个命令:

aws s3同步您的bucketnamedirectory您的localdirectory

例如,如果你的桶名是myBucket,本地目录是c:\local,那么:

aws s3 sync s3://myBucket c:\local

有关awscli的更多信息,请查看这个 Aws cli安装