# /etc/logrotate.d/ndn-mysql5-helper AND /dh/mysql/etc/ndn-mysql5-helper.logrotate

# dh_installdeb considers everything inside /etc/ to be a conffile.
# Under normal circumstances, if you remove a conffile from a live installation, then
# dpkg will not attempt to reinstall it upon package [re]installation.
# This has been a problem for us because I've ended up accidentally removing
# the ndn-mysql5-helper logrotate file in some cases.
# Why did I do that? 
# Because, since logrotate is a conffile, if you remove the package, then
# the logrotate file will still be there.
# But unfortunately, in cases where /dh/mysql/logs/ does not exist after the 
# package has been removed (often!), logrotate as a *whole* breaks because
# that directory does not exist!  (Note that the 'missingok' directive
# does *not* prevent this breakage).
# So.
# Here's how we're going to fix this problem:
# This file is stored in the package in /dh/mysql/etc/ndn-mysql5-helper.logrotate.
# Upon package installation, the postinst copies the file over to /etc/logrotate.d/ndn-mysql5-helper.
# That solves the problem of the missing logrotate file.
# Upon package removal, the prerm (*not* the postrm) will remove /etc/logrotate.d/ndn-mysql5-helper.
# Upon package upgrade, the prerm will remove /etc/logrotate.d/ndn-mysql5-helper, and *then* the 
# postinst will install copy over the /dh/mysql/etc/ndn-mysql5-helper.logrotate to /etc/logrotate.d/ndn-mysql5-helper.
# So there!
# JMS 3-6-06


# To rotate various mysql log files 

# Rotate MySQL general logs if size>200M when cron job runs or daily 
/dh/mysql/logs/*.log {
    daily
    rotate 28
    compress
    maxsize 200M
    delaycompress
    missingok
    sharedscripts
    postrotate
      /etc/init.d/mysqld flush-general-logs &> /dev/null
    endscript
}

# Rotate MySQL error logs daily when the cron job runs.
/dh/mysql/logs/*.err {
     daily
     rotate 28
     compress
     delaycompress
     missingok
     sharedscripts
     postrotate
       /etc/init.d/mysqld flush-error-logs &> /dev/null
     endscript
 }

# Rotate the mysql key_buffer log file.
# Rotate monthly.
# This is a small file, used to see how much key buffer is used 2 hours after starting mysql
/dh/mysql/logs/key_buffer_size/*.key {
	monthly
	size 5M
	rotate 6
	compress
	delaycompress
	missingok
}

# These files could get HUGE
# but they're not always there
/dh/mysql/logs/debug/*.debug {
	daily
	rotate 9 
	compress
	delaycompress
	missingok
}

# These files could get HUGE
# but they're not always there
/dh/mysql/logs/debug_user/*.log {
	daily
	rotate 9 
	compress
	size=1G
	delaycompress
	missingok
}
