Qmail Log Backup Script
From Qmailtoaster
Qmail Log Backup Script to backup your qmail log files without increasing the value of logsize and logcount control files by tar.gz-ed to another folder
Filename: /etc/cron.daily/backupqmaillog.sh so it can run everyday.
#!/bin/bash # # qmaillog backup utility # version 0.1 # pakogah@pala.bo-tak.info # 4 Aug 2007 # this qmaillog backup utility by default will backup # today qmail's send and smtp log into /home/backuplog # and keep it for the next 7 days # enhancement are always welcome
# where your qmail log folder # QMAILLOG=/var/log/qmail QMAILLOG=/var/log/qmail # what log is going to backup ? # by default only smtp and send log only # possible log to backup are: # LOGS="authlib clamd imap4 imap4-ssl pop3 pop3-ssl send smtp spamd submission" LOGS="send smtp" # your backup destination # folder will be created automatically # BACKUP_DEST=/home/backuplog BACKUP_DEST=/home/backuplog # how long you will save the backup # BACKUP_AGE=7 # days BACKUP_AGE=7 # days
# ============================ # process # ============================ DATE=`date +%Y%m%d` TMPFILE=/tmp/backuplist DAILY_AGE=1 # day DAILY_AGE_MINS=$[ $DAILY_AGE * 60 * 24 ] BACKUP_AGE_MINS=$[ $BACKUP_AGE * 60 * 24 ]
for i in $LOGS; do mkdir -p $BACKUP_DEST/$i find $QMAILLOG/$i/* -cmin -$DAILY_AGE_MINS -exec ls -1 {} \; > $TMPFILE tar czf $BACKUP_DEST/$i/$i-$DATE.tar.gz -T $TMPFILE rm -f $TMPFILE find $BACKUP_DEST/$i/*.tar.gz -cmin +$BACKUP_AGE_MINS -exec rm -f {} \; done # ============================
from http://www.mail-archive.com/qmailtoaster-list@qmailtoaster.com/msg14988.html