首页
学习
活动
专区
工具
TVP
发布

S3cmd

作者头像
yaohong
发布2019-09-11 15:37:23
1.4K0
发布2019-09-11 15:37:23
举报
文章被收录于专栏:姚红专栏姚红专栏

一:安装方法

#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
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-02-28 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一:安装方法
  • 二:使用方法
  • 三:文件夹处理规则
  • 四:同步方法
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档