上传:
#!/bin/bash
#docker server 01
/root/ossutil64 cp /opt/dockercn01/activity/ oss://gstarcad-logs/cn-gactivity/01/ --include "catalina.out*.gz" -r -u
下载:
#!/bin/bash
echo -e "\033[31m Please input system name \033[0m"
echo -e "\033[31m You can input name like:cn-user or us-user \033[0m"
read -p "Input a name:" name
line=`/home/gslog/ossutil64 ls oss://gstarcad-logs -s -d|grep -w "oss://gstarcad-logs/\$name"|wc -l`
if [ $line -lt 1 ];then
# echo -e "\033[31m please input right name \033[0m"
/home/gslog/ossutil64 ls oss://gstarcad-logs -s -d |awk -F '/' '{print $4}'
echo -e "\033[31m please input right name \033[0m"
exit 0
fi
echo -e "\033[31m You can input data like 20201110 or 20201225 ... \033[0m"
echo -e "\033[31m Notice If U want to download 20201121, U must input the 20201122 for data \033[0m"
read -p "Input a data:" data
line1=`/home/gslog/ossutil64 ls oss://gstarcad-logs/"\$name" -s|grep -w "\$data"|wc -l`
if [ $line1 -lt 1 ];then
# echo -e "\033[31m please input right date \033[0m"
/home/gslog/ossutil64 ls oss://gstarcad-logs/$name -s|awk -F '/' '{print $NF}'|awk -F '[-.]' '{print $3}'|sort -n|uniq -c|sort -nr|awk '{print $2}'
echo -e "\033[31m please input right date \033[0m"
exit 0
fi
echo -e "\033[32m download ........... \033[0m"
mkdir -p /tmp/$data
/home/gslog/ossutil64 cp oss://gstarcad-logs/$name/01/catalina.out-$data.gz /tmp/$data/s01-$name.gz
/home/gslog/ossutil64 cp oss://gstarcad-logs/$name/02/catalina.out-$data.gz /tmp/$data/s02-$name.gz
echo "unzip ............."
cd /tmp/$data && gzip -d s01-$name.gz && gzip -d s02-$name.gz
echo "all done."
echo -e "\033[32m Your logs is download and unzip OK,please to /tmp/$data \033[0m"
阿里云帮助文档:
https://help.aliyun.com/document_detail/120069.html?spm=a2c4g.11186623.6.856.547b7a6cTa0swz