<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: compress/tar archive mail dirs</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>I use a script to grab all quarantine dirs older than 5 days, compress them and then send them off to an ftp site. Uses ncftpput for the transfer. Could use some cleaning up....</FONT></P>
<P><FONT SIZE=2>#!/bin/bash</FONT>
<BR><FONT SIZE=2># /root/scripts/samsback.sh</FONT>
<BR><FONT SIZE=2># JVB - 09102003</FONT>
<BR><FONT SIZE=2># Quarantine Folder Backup Script</FONT>
<BR><FONT SIZE=2>#</FONT>
<BR><FONT SIZE=2># configure vars and add to crontab</FONT>
</P>
<P><FONT SIZE=2>QDIR=/var/spool/MailScanner/quarantine</FONT>
<BR><FONT SIZE=2>OLDERTHAN=5 # days</FONT>
<BR><FONT SIZE=2>SCRIPTDIR=/root/scripts</FONT>
<BR><FONT SIZE=2>HOST=hostname (or $(hostname)</FONT>
<BR><FONT SIZE=2>FTPHOST=ipofftpserver</FONT>
<BR><FONT SIZE=2>FTPUSER=ftpuser</FONT>
<BR><FONT SIZE=2>FTPPASS=ftppass</FONT>
<BR><FONT SIZE=2>FTPRMTDIR=/ftp/remote/dir</FONT>
</P>
<P><FONT SIZE=2>#</FONT>
<BR><FONT SIZE=2>#</FONT>
<BR><FONT SIZE=2>#</FONT>
<BR><FONT SIZE=2>#</FONT>
<BR><FONT SIZE=2>#</FONT>
</P>
<P><FONT SIZE=2>if [ ! -z $1 ];then</FONT>
<BR><FONT SIZE=2> SRC=$(echo $1 |cut -d/ -f6)</FONT>
<BR><FONT SIZE=2> if (tar czf $QDIR/$HOST.$SRC.tar.gz $QDIR/$SRC); then</FONT>
<BR><FONT SIZE=2> rm -rf $QDIR/$SRC</FONT>
<BR><FONT SIZE=2> ncftpput -V -DD -u $FTPUSER -p $FTPPASS $FTPHOST $FTPRMTDIR $QDIR/$HOST.$SRC.tar.gz</FONT>
<BR><FONT SIZE=2> else</FONT>
<BR><FONT SIZE=2> echo $QDIR/$SRC failed to compress...</FONT>
<BR><FONT SIZE=2> fi</FONT>
<BR><FONT SIZE=2>else</FONT>
<BR><FONT SIZE=2> find $QDIR -mtime +$OLDERTHAN -maxdepth 1 -type d -exec $SCRIPTDIR/samsback.sh {} \;</FONT>
<BR><FONT SIZE=2>fi</FONT>
</P>
<BR>
<BR>
<BR>
<P><FONT SIZE=2>> -----Original Message-----</FONT>
<BR><FONT SIZE=2>> From: Martin Hepworth [<A HREF="mailto:martinh@SOLID-STATE-LOGIC.COM">mailto:martinh@SOLID-STATE-LOGIC.COM</A>] </FONT>
<BR><FONT SIZE=2>> Sent: Friday, November 21, 2003 9:23 AM</FONT>
<BR><FONT SIZE=2>> To: MAILSCANNER@JISCMAIL.AC.UK</FONT>
<BR><FONT SIZE=2>> Subject: compress/tar archive mail dirs</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Hi all</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> anyone got a handy script that will find previous days </FONT>
<BR><FONT SIZE=2>> archive email dirs and compress/tar them up and delete the </FONT>
<BR><FONT SIZE=2>> directory afterwards?</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Could write something myself, but not wanting to re-invent </FONT>
<BR><FONT SIZE=2>> the wheel...</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> alternatively could this be an option in the Archive Mail </FONT>
<BR><FONT SIZE=2>> config so when it rolls over to the next dir, it tgz-ed (or </FONT>
<BR><FONT SIZE=2>> whatever) yesterdays archive directory??</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> --</FONT>
<BR><FONT SIZE=2>> Martin Hepworth</FONT>
<BR><FONT SIZE=2>> Snr Systems Administrator</FONT>
<BR><FONT SIZE=2>> Solid State Logic</FONT>
<BR><FONT SIZE=2>> Tel: +44 (0)1865 842300</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> **********************************************************************</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> This email and any files transmitted with it are confidential </FONT>
<BR><FONT SIZE=2>> and intended solely for the use of the individual or entity </FONT>
<BR><FONT SIZE=2>> to whom they are addressed. If you have received this email </FONT>
<BR><FONT SIZE=2>> in error please notify the system manager.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> This footnote confirms that this email message has been swept </FONT>
<BR><FONT SIZE=2>> for the presence of computer viruses and is believed to be clean.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> **********************************************************************</FONT>
<BR><FONT SIZE=2>> </FONT>
</P>
</BODY>
</HTML>