Created
March 20, 2013 18:39
-
-
Save mikedemers/5207277 to your computer and use it in GitHub Desktop.
Shell script that compresses log files and uses archiver.rb to send them to an S3 bucket. I run this from cron.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# TODO: this needs to be updated to work with logrotate... | |
BUDIR="/home/mike/backup/logs" | |
BUCKET="APPNAME-full-logs" | |
ARCHIVER="/home/mike/backup/bin/archiver.rb" | |
GZIP="/bin/gzip" | |
LOGDIR="/var/www/apps/APPNAME/shared/log" | |
DATETAG=`date +'%Y%m%d-%H%M%S'` | |
ALOGBU="${BUDIR}/access-${DATETAG}.log.gz" | |
PLOGBU="${BUDIR}/production-${DATETAG}.log.gz" | |
${GZIP} < ${LOGDIR}/access.log > "${ALOGBU}" | |
${GZIP} < ${LOGDIR}/production.log > "${PLOGBU}" | |
${ARCHIVER} "${BUCKET}" "${ALOGBU}" | |
${ARCHIVER} "${BUCKET}" "${PLOGBU}" | |
rm "${ALOGBU}" | |
rm "${PLOGBU}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment