码迷,mamicode.com
首页 > 其他好文 > 详细

迁移aws服务器日志到s3

时间:2017-04-10 13:45:52      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:日志迁移

#!/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 {} \;

本文出自 “小V运维之路” 博客,请务必保留此出处http://victor2016.blog.51cto.com/6768693/1914459

迁移aws服务器日志到s3

标签:日志迁移

原文地址:http://victor2016.blog.51cto.com/6768693/1914459

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!