m_region='cn-north-1'
base_url='backup/rdb/'
ndate=date +%Y%m%d --date "-10 days"
for each_bak_dir in aws --region ${m_region} s3 ls s3://${base_url} |grep PRE |grep -v current |awk '{print $2}' |sed 's#/##g'
;do
echo ${each_bak_dir}
each_bak_dir_num=echo ${each_bak_dir} | sed 's/-//g'
if [ ${each_bak_dir_num} -lt ${ndate} ];then
#echo ${each_bak_dir}
for del_time in seq -w 00 23 |egrep -v "10|12"
;do
#echo ${each_bak_dir}/${del_time}/
#aws --region ${m_region} s3 rm s3://${base_url}2017-08-15/00/ --recursive
aws --region ${m_region} s3 rm s3://${base_url}${each_bak_dir}/${del_time}/ --recursive
done
fi
done