aliyun OOS 资源同步【ossutil】

#!/bin/bash
#同步远程图片到OSS Bucket中
#@author <lixiuran>
# https://help.aliyun.com/document_detail/120069.html?spm=a2c4g.11186623.6.704.63e424bcZQvfKY
SRC_DIR=$(pwd)"/src" echo "SRC DIR:"${SRC_DIR} mkdir -p ${SRC_DIR} for i in `cat ./public.txt|awk '{print $NF}'|grep '\.'|grep 'Contract'`;do #echo $i|awk -F '/' '{print $NF}' echo "创建目录:"${i%/*} echo "当前文件:"$i mkdir -p ${SRC_DIR}"/"${i%/*} if [ -f ${SRC_DIR}"/"${i} ];then echo "文件已存在" else #不存在即下载 wget -P ${SRC_DIR}"/"${i%/*} "http://www.xxx.com/"$i fi SUB_NAME=${i/Public/} echo $SUB_NAME ./ossutilmac64 appendfromfile ${SRC_DIR}"/"$i "oss://cdn-test"${SUB_NAME} if [ $? -ne 0 ]; then echo "failed" exit else echo "succeed" fi done

public.txt 为资源文件(通过  find ./Public -ctime -1 -ls 拿到最近一天修改的文件列表)

猜你喜欢

转载自www.cnblogs.com/lixiuran/p/12716211.html
今日推荐