1.将日志备份推送到s3存储上
#!/bin/sh
# 此脚本实现将/usr/local/netqin/boss/netqin/logs/BOSS_ContentServer/BOSS_AD_SDK 目录下的日志
# 按月按日志类别 tar 打包备份
# by libaolin
# 目录变量
BUSINESS_PASH=/usr/local/boss/logs/BOSS_ContentServer/BOSS_SDK/
# 本机内网IP
IP=`/sbin/ifconfig| grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
# 前一天的日期(按天备份)
LAST_DAY=`date -d "-1day" +%Y-%m-%d`
# 备份BOSS_ADS_ADLOG_DailyRolling 日志
cd ${BUSINESS_PASH} && /bin/tar zcf /ADSDK_log_bak/BOSS_ADS_ADLOG_DailyRolling/BOSS_ADS_ADLOG_DailyRolling.log.${LAST_DAY}_${IP}.tar.gz BOSS_ADS_ADLOG_DailyRolling.log.${LAST_DAY}
# aws s3 cp /ADSDK_log_bak/bak_db_adsdk/${DATE_TIME}_adsdk.sql.tar.gz s3://adsdk-server/adsdk_db/
aws s3 cp /ADSDK_log_bak/BOSS_ADS_ADLOG_DailyRolling/BOSS_ADS_ADLOG_DailyRolling.log.${LAST_DAY}_${IP}.tar.gz s3://adsdk-server/adsdk_log_bak/BOSS_ADS_ADLOG_DailyRolling/
# 备份BOSS_ADS_DailyRolling 日志
cd ${BUSINESS_PASH} && /bin/tar zcf /ADSDK_log_bak/BOSS_ADS_DailyRolling/BOSS_ADS_DailyRolling.log.${LAST_DAY}_${IP}.tar.gz BOSS_ADS_DailyRolling.log.${LAST_DAY}
aws s3 cp /ADSDK_log_bak/BOSS_ADS_DailyRolling/BOSS_ADS_DailyRolling.log.${LAST_DAY}_${IP}.tar.gz s3://adsdk-server/adsdk_log_bak/BOSS_ADS_DailyRolling/
# 通过s3 sync 推送数据
# cd /ADSDK_log_bak/BOSS_ADS_ADLOG_DailyRolling/ && /usr/bin/aws s3 sync ${yestoday_with_separator} s3://adsdk-server/adsdk-emr/InputDate/${yestoday_with_separator} --quiet
# 清理业务日志 5 天前
#cd ${BUSINESS_PASH} && /bin/rm -f /usr/local/netqin/boss/netqin/logs/BOSS_ContentServer/BOSS_AD_SDK/BOSS_ADS_ADLOG_DailyRolling.log.${LAST_DAY_SEVEN}
#cd ${BUSINESS_PASH} && /bin/rm -f /usr/local/netqin/boss/netqin/logs/BOSS_ContentServer/BOSS_AD_SDK/BOSS_ADS_DailyRolling.log.${LAST_DAY_SEVEN}
cd ${BUSINESS_PASH} && find -type f -name "*log*" -mtime +1 |xargs rm -f
# 清理压缩日志 5 天前
#/bin/rm -f /ADSDK_log_bak/BOSS_ADS_ADLOG_DailyRolling/BOSS_ADS_ADLOG_DailyRolling.log.${LAST_DAY_SEVEN}_${IP}.tar.gz
#/bin/rm -f /ADSDK_log_bak/BOSS_ADS_DailyRolling/BOSS_ADS_DailyRolling.log.${LAST_DAY}_${IP}.tar.gz
cd /ADSDK_log_bak/BOSS_ADS_ADLOG_DailyRolling/ && find -type f -name "*log*" -mtime +4 |xargs rm -f
cd /ADSDK_log_bak/BOSS_ADS_DailyRolling/ && find -type f -name "*log*" -mtime +4 |xargs rm -f