/etc/logrotate.d/httpd
If you want to backup apache logs for all instances (you can copy this logrotate script/snippet in /etc/logrotate.d/httpd)
Prerequisite: setup s3cmd
/var/log/httpd/*log {
daily
dateext
#dateext dateformat -%Y-%m-%d-%s
missingok
notifempty
#size 3M
sharedscripts
delaycompress
rotate 4
create
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
BUCKET=logs-backup
INSTANCE_ID=`curl --silent http://169.254.169.254/latest/meta-data/instance-id`
/usr/local/bin/s3cmd -c /root/.s3cfg -m text/plain sync /var/log/httpd/access_log* s3://${BUCKET}/system_logs/httpd/${INSTANCE_ID}/
/usr/local/bin/s3cmd -c /root/.s3cfg -m text/plain sync /var/log/httpd/error_log* s3://${BUCKET}/system_logs/httpd/${INSTANCE_ID}/
endscript
}
If you want to backup apache logs for all instances (you can copy this logrotate script/snippet in /etc/logrotate.d/httpd)
Prerequisite: setup s3cmd
/var/log/httpd/*log {
daily
dateext
#dateext dateformat -%Y-%m-%d-%s
missingok
notifempty
#size 3M
sharedscripts
delaycompress
rotate 4
create
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
BUCKET=logs-backup
INSTANCE_ID=`curl --silent http://169.254.169.254/latest/meta-data/instance-id`
/usr/local/bin/s3cmd -c /root/.s3cfg -m text/plain sync /var/log/httpd/access_log* s3://${BUCKET}/system_logs/httpd/${INSTANCE_ID}/
/usr/local/bin/s3cmd -c /root/.s3cfg -m text/plain sync /var/log/httpd/error_log* s3://${BUCKET}/system_logs/httpd/${INSTANCE_ID}/
endscript
}
No comments:
Post a Comment