Monday, October 24, 2005

A simple script to compress mailbox

#
# This script is used to compress mailbox
#
# Thu Aug 26 17:18:02 CEST 2005
#

source /sbin/functions.sh

MAILDIR="/home/user/.maildir"
CURRENT_DATE=`date +"%d%m%y"`

MBOX_TO_ARCHIVE="gentoo-announce gentoo-gwn gentoo-other gentoo-security gentoo-server"

ebegin "Archiving mail folder"
echo " -------------------------"

for folder in $MBOX_TO_ARCHIVE
do
ebegin "Archiving $folder"

if [ -e $MAILDIR/$folder-$CURRENT_DATE.gz ]; then
eerror "Error \"$folder-$CURRENT_DATE.gz\" exist!"
exit 1
else
cat $MAILDIR/$folder | gzip - > $MAILDIR/$folder-$CURRENT_DATE.gz
if [ ! ${?} ] ; then
eerror "Error while archiving $folder!"
exit 1
fi
: > $MAILDIR/$folder
eend ${?}
fi
done

No comments:

Post a Comment