QmailtoasterMain Page | About | Help | FAQ | Special pages | Log in

Printable version | Disclaimers | Privacy policy

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

Retrieved from "http://wiki.qmailtoaster.com/index.php/Qmail_Log_Backup_Script"

This page has been accessed 2,077 times. This page was last modified on 15 October 2010, at 07:02. Content is available under GNU Free Documentation License 1.2.


Find

Browse
Main page
Community portal
Current events
Recent changes
Random page
Help
Edit
View source
Editing help
This page
Discuss this page
New section
Printable version
Context
Page history
What links here
Related changes
My pages
Log in / create account
Special pages
New pages
File list
Statistics
More...