[Dovecot] compression script for use with zlib module
Hi,
I'm wondering if someone already implemented a compression script
(and would like to share it) based on the step-by-step provided on wiki page of Zlib module.
I can already do some find|xargs gzip .... but couldnt implement it
completly as described on the wiki page. I know the suggested step-by-step is very detailed and probably a must simplier will be enough for almost anyone .... anyway, if someone have the full script and would like to share it, i would be glad to get it :)
http://wiki.dovecot.org/Plugins/Zlib
- Find the mails you want to compress in a single maildir.
- Compress the mails to tmp/
the original files (e.g. touch command)
- Update the compressed files' mtimes to be the same as they were in
- Run maildirlock <path> <timeout>. It writes PID to stdout, save it.
directory, if it's separate)
- <path> is path to the Maildir's dovecot-uidlist (the control
- <timeout> specifies how long to wait for the lock before failing.
- If maildirlock grabbed the lock successfully (exit code 0) you can continue.
- For each mail you compressed:
- Verify that it still exists where you last saw it.
- If it doesn't exist, delete the compressed file. Its flags may have been changed or it may have been expunged. This happens rarely, so just let the next run handle it.
- If the file does exist, rename() (mv) the compressed file over the original file. * Dovecot can now read the file, but to avoid compressing it again on the next run, you'll probably want to rename it again to include e.g. a "Z" flag in the file name to mark that it was compressed (e.g. 1223212411.M907959P17184.host,S=3271:2,SZ). Remember that the Maildir specifications require that the flags are sorted by their ASCII value, although Dovecot itself doesn't care about that.
- Unlock the maildir by sending a TERM signal to the maildirlock process (killing the PID it wrote to stdout).
--
Atenciosamente / Sincerily,
Leonardo Rodrigues
Solutti Tecnologia
http://www.solutti.com.br
Minha armadilha de SPAM, NÃO mandem email
gertrudes@solutti.com.br
My SPAMTRAP, do not email it
Hi,
I´m using the following two scripts:
zip-list.sh:
find "$home"
-type f
-name '*,S=*'
-mtime +1
-size +10k
The above script list the files that will be compressed.
zip-compressh.sh #!/bin/bash
uid='vmail' gid='vmail'
sleepOnFailure='2'
cat zip-list.txt|while read i do if [ ! -f "$i" ] then continue fi
type=$(file -bi "$i")
fgrep 'message/rfc822' <<<"$type" >/dev/null
if [ "$?" != '0' ]
then
continue;
fi
echo -n "$i..."
modify=$(stat -c %y "$i"|cut -d. -f1)
basename=$(basename "$i")
gzip -9 -c "$i" >/tmp/"$basename"
mv /tmp/"$basename" "$i"
exitStatus="$?"
while [ -f "$i" -a "$exitStatus" != '0' ]
do
echo -n "wait($sleepOnFailure)..."
sleep "$sleepOnFailure"
mv /tmp/"$basename" "$i" 2>/dev/null
exitStatus="$?"
done
chown "$uid"."$gid" "$i"
touch -m -d "$modify" "$i"
echo "OK"
done
This script reads the zip-list.txt and compress the file. We do not lock the maildir, but we use touch to maintain original dates. We do not check any 'Z' flags.
[]s Fernando
Hi, I'm wondering if someone already implemented a compression script
(and would like to share it) based on the step-by-step provided on wiki page of Zlib module.
I can already do some find|xargs gzip .... but couldnt implement it
completly as described on the wiki page. I know the suggested step-by-step is very detailed and probably a must simplier will be enough for almost anyone .... anyway, if someone have the full script and would like to share it, i would be glad to get it :)
http://wiki.dovecot.org/Plugins/Zlib
- Find the mails you want to compress in a single maildir.
- Compress the mails to tmp/ the original files (e.g. touch command)
- Update the compressed files' mtimes to be the same as they were in
- Run maildirlock <path> <timeout>. It writes PID to stdout, save it. directory, if it's separate)
- <path> is path to the Maildir's dovecot-uidlist (the control
- <timeout> specifies how long to wait for the lock before failing.
- If maildirlock grabbed the lock successfully (exit code 0) you can continue.
- For each mail you compressed:
- Verify that it still exists where you last saw it.
- If it doesn't exist, delete the compressed file. Its flags may have been changed or it may have been expunged. This happens rarely, so just let the next run handle it.
- If the file does exist, rename() (mv) the compressed file over the original file. * Dovecot can now read the file, but to avoid compressing it again on the next run, you'll probably want to rename it again to include e.g. a "Z" flag in the file name to mark that it was compressed (e.g. 1223212411.M907959P17184.host,S=3271:2,SZ). Remember that the Maildir specifications require that the flags are sorted by their ASCII value, although Dovecot itself doesn't care about that.
- Unlock the maildir by sending a TERM signal to the maildirlock process (killing the PID it wrote to stdout).
--
Atenciosamente / Sincerily, Leonardo Rodrigues Solutti Tecnologia http://www.solutti.com.br
Minha armadilha de SPAM, NÃO mandem email gertrudes@solutti.com.br My SPAMTRAP, do not email it
participants (2)
-
fernando@dfcom.com.br
-
Leonardo Rodrigues