我在服務器上有一大堆文件,我想將它們上傳到S3上。這些文件以.data擴展名存儲,但實際上它們只是一堆jpegs,png,zip或pdf。使用s3cmd並行上傳文件到s3
我已經寫了一個簡短的腳本,它可以找到mime類型並將它們上載到S3上,並且可以工作,但速度很慢。有沒有辦法使用gnu parallel進行下面的運行?
#!/bin/bash
for n in $(find -name "*.data")
do
data=".data"
extension=`file $n | cut -d ' ' -f2 | awk '{print tolower($0)}'`
mimetype=`file --mime-type $n | cut -d ' ' -f2`
fullpath=`readlink -f $n`
changed="${fullpath/.data/.$extension}"
filePathWithExtensionChanged=${changed#*internal_data}
s3upload="s3cmd put -m $mimetype --acl-public $fullpath s3://tff-xenforo-data"$filePathWithExtensionChanged
response=`$s3upload`
echo $response
done
此外,我敢肯定,這個代碼可以大大提高一般:)反饋提示將不勝感激。
並行上傳可以使用Python和博託 – helloV 2014-11-14 19:07:53
點頭,我可以寫在旅途中或其他語言的東西,但我試圖做到這一點「所有在bash」對於沒有特別的理由。 – 2014-11-14 19:09:35
[可能的解決方案](http://blog.aclarke.eu/moving-copying-lots-of-s3-files-quickly-using-gnu-parallel/) – helloV 2014-11-14 19:13:18