如何使用命令行将文件从Amazon EC2移到S3存储桶 [英] How to move files from amazon ec2 to s3 bucket using command line

查看:275
本文介绍了如何使用命令行将文件从Amazon EC2移到S3存储桶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Amazon EC2实例中,我有一个名为 uploads 的文件夹。在此文件夹中,我有1000张图像。现在,我要将所有图像复制到新的S3存储桶中。我该怎么做?

In my amazon EC2 instance, I have a folder named uploads. In this folder I have 1000 images. Now I want to copy all images to my new S3 bucket. How can I do this?

推荐答案

第一个选项sm3cmd



使用 s3cmd

s3cmd get s3://AWS_S3_Bucket/dir/file

看看此s3cmd文档

如果您使用的是Linux,请在命令行上运行:

if you are on linux, run this on the command line:

sudo apt-get install s3cmd

或费多雷的Centos。

or Centos, Fedore.

yum install s3cmd

用法示例:

s3cmd put my.file s3://pactsRamun/folderExample/fileExample



第二个选项



使用来自亚马逊的Cli

就像@ tedder42在评论中说的那样,请使用 sync ,而不要使用 cp

Like @tedder42 said in the comments, instead of using cp, use sync.

看看以下语法:

aws s3 sync <source> <target> [--options]

示例:

aws s3 sync . s3://my-bucket/MyFolder

更多信息和示例,请参见使用高级s3命令和AWS命令行界面

More information and examples available at Managing Objects Using High-Level s3 Commands with the AWS Command Line Interface

这篇关于如何使用命令行将文件从Amazon EC2移到S3存储桶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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