迁移aws服务器日志到s3

#!/bin/bash

#install s3cmd
cd /etc/yum.repos.d
wget http://s3tools.org/repo/RHEL_6/s3tools.repo
if [ ! -d "/usr/local/scripts/" ] ; then 
mkdir -p /usr/local/scripts/;
fi

#upload the migrate logs script to /usr/local/scripts
scp $ATTACH_DIR/migrate-log.sh /usr/local/scripts

echo  "0 */1 * * * /usr/local/scripts/migrate-log.sh > /dev/null 2>&1" >>/var/spool/cron/root 

#add crontab entry


#upload backup files to s3

DATE=`date +%Y-%m-%d`


cd /mnt/ephemeral/karaf/data/

tar zcvf web-messaging-service.log.${DATE}tar.gz log

#save a copy to s3
s3cmd put --force web-messaging-service.log.${DATE}tar.gz s3://wms-gameexternal-log/

rm -f /mnt/ephemeral/karaf/data/web-messaging-service.log.${DATE}tar.gz

find /mnt/ephemeral/karaf/data/log/ -type f  -name   "karaf.log.20*" -exec rm -f {} \;
















本文转自chenzudao51CTO博客,原文链接:http://blog.51cto.com/victor2016/1914459 ,如需转载请自行联系原作者


上一篇:大数据给网络运营带来了什么


下一篇:log4net.dll配置以及在项目中应用 zt