专栏中心

EEPW首页 > 专栏 > 支持S3协议的S3cmd工具简单使用

支持S3协议的S3cmd工具简单使用

发布人:天翼云开发者 时间:2024-08-12 来源:工程师 发布文章

本文分享自天翼云开发者社区《支持S3协议的S3cmd工具简单使用》,作者:付****健

一:安装方法

#wget http://nchc.dl.sourceforge.net/project/s3tools/s3cmd/1.0.0/s3cmd-1.0.0.tar.gz

#tar -zxf s3cmd-1.0.0.tar.gz -C /usr/local/   

#mv /usr/local/s3cmd-1.0.0/ /usr/local/s3cmd/   

#ln -s /usr/local/s3cmd/s3cmd /usr/bin/s3cmd


二:使用方法

1.配置Access Key ID 和 Secret Access Key

 #s3cmd --configure

2.列举所有的Buckets

#s3cmd ls

3.创建 bucket,且 bucket 名称是唯一的,不能重复。

#s3cmd mb s3://my-bucket-name

4.删除空 bucket

#s3cmd rb s3://my-bucket-name

5.列举 Bucket 中的内容

#s3cmd ls s3://my-bucket-name

6.上传 file.txt 到某个 bucket

#s3cmd put file.txt s3://my-bucket-name/file.txt

7.上传并将权限设置为所有人可读

#s3cmd put --acl-public file.txt s3://my-bucket-name/file.txt

8.批量上传文件

#s3cmd put ./* s3://my-bucket-name/

9.下载文件

#s3cmd get s3://my-bucket-name/file.txt file.txt

10.批量下载

#s3cmd get s3://my-bucket-name/* ./

11.删除文件

#s3cmd del s3://my-bucket-name/file.txt

12.来获得对应的bucket所占用的空间大小

#s3cmd du -H s3://my-bucket-name


三:文件夹处理规则

带"/"斜杠的 dir1,相当于上传yh目录下的所有文件,即类似 "cp ./* "

# s3cmd put -r yh s3://yaohong-bucket

  upload: 'yh/1' -> 's3://yaohong-bucket/yh/1' [1 of 4]

  0 of 0 0% in 0s 0.00 B/s done

  upload: 'yh/2' -> 's3://yaohong-bucket/yh/2' [2 of 4]

  0 of 0 0% in 0s 0.00 B/s done

  upload: 'yh/3.py' -> 's3://yaohong-bucket/yh/3.py' [3 of 4]

  0 of 0 0% in 0s 0.00 B/s done

  upload: 'yh/3.sh' -> 's3://yaohong-bucket/yh/3.sh' [4 of 4]

  0 of 0 0% in 0s 0.00 B/s done


四:同步方法

1.同步当前目录下所有文件

#s3cmd sync  ./  s3://yaohong-bucket/

2.加 “--dry-run”参数后,仅列出需要同步的项目,不实际进行同步。

#s3cmd sync  --dry-run ./  s3://my-bucket-name/

3.加 “--delete-removed”参数后,会删除本地不存在的文件。

#s3cmd sync  --delete-removed ./  s3://my-bucket-name/

4.加 “--skip-existing”参数后,不进行MD5校验,直接跳过本地已存在的文件。

#s3cmd sync  --skip-existing ./  s3://my-bucket-name/


五:高级同步

排除、包含规则(--exclude 、--include)

file1-1.txt被排除,file2-2.txt同样是txt格式却能被包含

# s3cmd sync --dry-run --exclude '*.txt' --include 'dir2/*' ./  s3://my-bucket-name/

exclude: dir1/file1-1.txt

upload: ./dir2/file2-2.txt -> s3://my-bucket-name/dir2/file2-2.txt

从文件中载入排除或包含规则。(--exclude-from、--include-from)

#s3cmd sync  --exclude-from pictures.exclude ./  s3://my-bucket-name/

排除或包含规则支持正则表达式

--rexclude 、--rinclude、--rexclude-from、--rinclude-from

专栏文章内容及配图由作者撰写发布,仅供工程师学习之用,如有侵权或者其他违规问题,请联系本站处理。 联系我们

关键词: S3 云计算

相关推荐

由Memfault驱动的Nordic nRF Cloud荣获移动突破奖所颁发之年度云计算创新奖

仿人型机器人能同时流利地说15种语言

“英伟达亲儿子”CoreWeave提交IPO申请,去年收入暴涨8倍

智能计算 2025-03-04

全球云计算市场迎来重大价格调整

2026-02-10

将AI工作负载推向边缘

边缘计算与人工智能(Edge AI)如何引领新一轮技术革命

云计算掀起智能硬件变革的浪潮

云计算在IC设计中的应用

Upwind筹集2.5亿美元以实现云安全规模化

美图获阿里巴巴2.5亿美元战略投资,将在AI与电商领域深度合作

应用于数据中心(DataCenter)的 Smarter Solution

视频 2014-02-14

打造可靠的云存储技术

十分钟让三星GALAXY S3享受无线充电

软件安全成为嵌入式云计算的热点

2016物联网大会宣传片

台积电AI产能:英伟达的需求可能迫使实现翻倍

Philips P51XA-S3 16位单片机资料

消息称谷歌首款 AR 眼镜年内上市售卖,将在本周 I/O 大会发布

更多 培训课堂
更多 焦点
更多 视频

技术专区