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