下载整个 S3 存储桶? [英] Downloading an entire S3 bucket?

查看:48
本文介绍了下载整个 S3 存储桶?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I noticed that there does not seem to be an option to download an entire s3 bucket from the AWS Management Console.

有没有一种简单的方法可以抓取我的一个桶中的所有东西?我正在考虑将根文件夹设为公开,使用 wget 获取所有内容,然后再次将其设为私有,但我不知道是否有更简单的方法.

Is there an easy way to grab everything in one of my buckets? I was thinking about making the root folder public, using wget to grab it all, and then making it private again but I don't know if there's an easier way.

推荐答案

AWS CLI

有关更多信息,请参阅AWS CLI 命令参考".

AWS 最近发布了他们的命令行工具,其工作方式与 boto 非常相似,可以使用

AWS recently released their Command Line Tools, which work much like boto and can be installed using

sudo easy_install awscli

sudo pip install awscli

安装后,您只需运行:

aws s3 sync s3://<source_bucket> <local_destination>

例如:

aws s3 sync s3://mybucket .

mybucket中的所有对象下载到当前目录.

will download all the objects in mybucket to the current directory.

并且会输出:

download: s3://mybucket/test.txt to test.txt
download: s3://mybucket/test2.txt to test2.txt

这将使用单向同步下载您的所有文件.除非您指定 不会删除您当前目录中的任何现有文件rel="noreferrer"> --delete,它不会更改或删除 S3 上的任何文件.

This will download all of your files using a one-way sync. It will not delete any existing files in your current directory unless you specify --delete, and it won't change or delete any files on S3.

您还可以进行 S3 存储桶到 S3 存储桶的同步,或本地到 S3 存储桶的同步.

You can also do S3 bucket to S3 bucket, or local to S3 bucket sync.

查看文档和其他示例.

虽然上面的例子是如何下载一个完整的bucket,你也可以通过执行递归下载一个文件夹

Whereas the above example is how to download a full bucket, you can also download a folder recursively by performing

aws s3 cp s3://BUCKETNAME/PATH/TO/FOLDER LocalFolderName --recursive

这将指示 CLI 在 BUCKETNAME 存储桶内的 PATH/TO/FOLDER 目录中递归下载所有文件和文件夹密钥.

This will instruct the CLI to download all files and folder keys recursively within the PATH/TO/FOLDER directory within the BUCKETNAME bucket.

这篇关于下载整个 S3 存储桶?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆