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

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


当前回答

您可以使用sync来下载整个S3桶。例如,下载当前目录下名为bucket1的整个桶。

aws s3 sync s3://bucket1 .

其他回答

您有许多选项可以做到这一点,但最好的是使用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.

100%为我工作,我已经下载了所有的文件从aws s3备份。

安装AWS CLI。选择您的操作系统并按照以下步骤操作:安装或更新AWS CLI的最新版本 检查AWS版本:AWS——version

执行config命令:aws configure

Aws s3 cp s3://yourbucketname你的\本地\路径——递归

例如(Windows操作系统):aws s3 cp s3://yourbucketname C:\aws-s3-backup\project-name——recursive

请查看此链接:如何从S3下载整个存储桶到本地文件夹

使用boto3下载具有特定前缀的桶中的所有对象

import boto3

s3 = boto3.client('s3', region_name='us-east-1', 
                     aws_access_key_id=AWS_KEY_ID, 
                     aws_secret_access_key=AWS_SECRET)

def get_all_s3_keys(bucket,prefix):
    keys = []

    kwargs = {'Bucket': bucket,Prefix=prefix}
    while True:
        resp = s3.list_objects_v2(**kwargs)
        for obj in resp['Contents']:
             keys.append(obj['Key'])

        try:
            kwargs['ContinuationToken'] = resp['NextContinuationToken']
        except KeyError:
            break

        return keys

def download_file(file_name, bucket,key):
    file=s3.download_file(
    Filename=file_name,
    Bucket=bucket,
    Key=key)
    return file

bucket="gid-folder"
prefix="test_"
keys=get_all_s3_keys(bucket,prefix):

for key in keys:
     download_file(key, bucket,key)
   
 

只需要在aws s3 cp命令中传递——recursive &——include "*",如下:aws——region "${BUCKET_REGION}" s3 cp s3://${BUCKET}${BUCKET_PATH}/ ${LOCAL_PATH}/tmp——recursive——include "*" 2>&1

另一个可以帮助一些OS X用户的选项是Transmit。

它是一个FTP程序,还可以让您连接到S3文件。而且,它有一个选项,可以将任何FTP或S3存储作为文件夹挂载在Finder中,但这只是在有限的时间内。