"); //-->
本文分享自天翼云开发者社区《支持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
专栏文章内容及配图由作者撰写发布,仅供工程师学习之用,如有侵权或者其他违规问题,请联系本站处理。 联系我们
相关推荐
消费电子云方案
由Memfault驱动的Nordic nRF Cloud荣获移动突破奖所颁发之年度云计算创新奖
仿人型机器人能同时流利地说15种语言
“英伟达亲儿子”CoreWeave提交IPO申请,去年收入暴涨8倍
云的数据安全与监控
全球云计算市场迎来重大价格调整
将AI工作负载推向边缘
F5基于云计算平台的虚拟桌面连接解决方案
边缘计算与人工智能(Edge AI)如何引领新一轮技术革命
使用JLink间接烧写S3C2410、S3C2440开发板Nor、Nand Flash的方法
云计算掀起智能硬件变革的浪潮
云计算在IC设计中的应用
Upwind筹集2.5亿美元以实现云安全规模化
美图获阿里巴巴2.5亿美元战略投资,将在AI与电商领域深度合作
各位大虾有没有用过net-start(s3c4510b)的linux2。0
Android云计算之移动点餐系统分析与设计
基于云计算技术的日志管理系统
应用于数据中心(DataCenter)的 Smarter Solution
可平滑播放MPEG1、MPEG4多媒体文件的ARM板
打造可靠的云存储技术
十分钟让三星GALAXY S3享受无线充电
软件安全成为嵌入式云计算的热点
2016物联网大会宣传片
何为“云计算”
台积电AI产能:英伟达的需求可能迫使实现翻倍
IT有明天:大转换中的云计算
Philips P51XA-S3 16位单片机资料
消息称谷歌首款 AR 眼镜年内上市售卖,将在本周 I/O 大会发布