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

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

问题描述

在我的亚马逊 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?

推荐答案

First Option 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、Fedore.

or Centos, Fedore.

yum install s3cmd

用法示例:

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

第二个选项

使用 来自亚马逊的 Cli

就像@tedder42 在评论中所说的,不要使用 cp,而是使用 sync.

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

更多信息和示例可在 通过 AWS 命令​​行界面使用高级 s3 命​​令管理对象

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

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

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