A menudo ponemos en marcha un cacti y luego los logs de dudoso interes a largo plazo se nos comen.
vzyum <id> install logrotate
y dentro del contenedor creamos el archivo de back-up:
touch /var/www/cacti/log/cacti_dump.sql
editamos el archivo : /etc/logrotate.d/cacti
# logrotate cacti.log
/var/www/cacti/log/cacti.log {
# keep 7 versions online
rotate 7
# rotate each day
daily
# don’t compress, but
# if disk space is an issue, change to
# compress
nocompress
# create new file with attributes
create 644 cacti cacti
# add a YYYYMMDD extension instead of a number
dateext
}# logrotate sql dump file
/var/www/cacti/log/cacti_dump.sql {
# keep 31 generations online
rotate 31
# create a daily dump
daily
# don’t compress the dump
nocompress
# create using this
create 644 cacti cacti
# append a nice date to the file
dateext
# delete all generations older than 31 days
maxage 31
# run this script AFTER rotating the previous cacti_dump.sql file
# make sure to use the correct database, user and password, see ./include/config.php
prerotate
/usr/bin/mysqldump –user= –password=
–lock-tables –add-drop-database –add-drop-table cacti > /var/www/cacti/log/cacti_dump.sql
endscript
lo probamos:
-bash-3.1# logrotate -fd /etc/logrotate.d/cacti
reading config file /etc/logrotate.d/cacti
reading config info for /var/www/cacti/log/cacti.log
reading config info for /var/www/cacti/log/cacti_dump.sqlHandling 2 logs
rotating pattern: /var/www/cacti/log/cacti.log forced from command line (7 rotations)
empty log files are rotated, old logs are removed
considering log /var/www/cacti/log/cacti.log
log needs rotating
rotating log /var/www/cacti/log/cacti.log, log->rotateCount is 7
glob finding old rotated logs failed
renaming /var/www/cacti/log/cacti.log to /var/www/cacti/log/cacti.log-20080427
creating new log mode = 0644 uid = 100 gid = 101rotating pattern: /var/www/cacti/log/cacti_dump.sql forced from command line (31 rotations)
empty log files are rotated, old logs are removed
considering log /var/www/cacti/log/cacti_dump.sql
log needs rotating
rotating log /var/www/cacti/log/cacti_dump.sql, log->rotateCount is 31
glob finding old rotated logs failed
running prerotate script
running script with arg /var/www/cacti/log/cacti_dump.sql : ”
/usr/bin/mysqldump –user=cactiuser –password=cactipass –lock-tables –add-drop-database –add-drop-table cacti > /var/www/cacti/log/cacti_dump.sql
”
renaming /var/www/cacti/log/cacti_dump.sql to /var/www/cacti/log/cacti_dump.sql-20080427
creating new log mode = 0644 uid = 100 gid = 101
Bueno teneis un poco de info en: http://docs.cacti.net
I’m imsdesper. You’ve really raised the bar with that.