Bucket使用定量 配額使用情況
http://s3tools.org/s3cmd-sync
配置。主要是 Access Key ID 和 Secret Access Key
s3cmd --configure
列舉所有的buckets
s3cmd ls
建立bucket 且bucket名稱不是唯一的,不能重複。
s3cmd mb s3://my-bucket-name/
删除空的bucket
s3cmd rb s3://my-bucket-name/
列舉buck中的内容
s3cmd ls s3://my-bucket-name/
上傳file.txt到某個bucket.
s3cmd put file.txt s3://my-bucket-name/
上傳某個檔案夾下的所有檔案到 bucket
s3cmd put ~/ca/ s3://my-bucket-name/
獲得對應的bucket所占用的空間大小
s3cmd du -H s3://my-bucet-name
上傳檔案夾
dir 不帶”/”斜杠,那麼dir1會作為檔案路徑的一部分,相當于上傳了整個dir1目錄,類似于cp -r dir1/
s3cmd put -r dir1 s3://my-bucket-name/
dir帶”/”斜杠,相當于上傳目錄下的所有檔案,不上傳檔案夾。
s3cmd put -r dir1/ s3://my-bucket-name/
删除檔案夾:删除ca檔案夾
删除bucket中的一個檔案夾就是先将檔案夾中的所有檔案都删除。
s3cmd del s3://new_/ca/*
擷取bucket或檔案的各種資訊
s3cmd info s3://new_/ca/ca.crt
在bucket之間拷貝對象
s3cmd cp s3://new_/ca/ca.crt s3://test_/
在bucket之間拷貝檔案夾
s3cmd cp -r s3://new_/ca s3://test_/
Modify object metadata
s3cmd modify s3://BUCKET1/OBJECT
~$ s3cmd put --acl-public --guess-mime-type storage.jpg s3://logix.cz-test/storage.jpg
File ‘storage.jpg’ stored as s3://logix.cz-test/storage.jpg (33045 bytes)
Public URL of the object is: http://logix.cz-test.s3.amazonaws.com/storage.jpg
4.1、正常同步操作
1、同步目前目錄下所有檔案
s3cmd sync ./ s3://my-bucket-name/
2、加 "–dry-run"參數後,僅列出需要同步的項目,不實際進行同步。
s3cmd sync -v -r --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/
5、進階同步操作
4.2.1、排除、包含規則(–exclude 、–include)
file1-1.txt被排除,file2-2.txt同樣是txt格式卻能被包含。
~/demo$ 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
4.2.2、從檔案中載入排除或包含規則。(–exclude-from、–include-from)
s3cmd sync --exclude-from pictures.exclude ./ s3://my-bucket-name/
4.2.3、排除或包含規則支援正規表達式
–rexclude 、–rinclude、–rexclude-from、–rinclude-from