/usr/local/directadmin/scripts/dovecot_compress.sh /home/user/imap/domain.com/email/Maildir
Checking for directories in /home/user/imap/domain.com/email/Maildir...
Size before compression: 16M
Compressed /home/user/imap/domain.com/email/Maildir/./cur...
Size after compression: 6.1M
du -h Maildir/
4.0K Maildir/.INBOX.IsGeenSpam/new
4.0K Maildir/.INBOX.IsGeenSpam/tmp
4.0K Maildir/.INBOX.IsGeenSpam/cur
20K Maildir/.INBOX.IsGeenSpam
12K Maildir/cur/tmp
6.1M Maildir/cur
4.0K Maildir/.Drafts/new
4.0K Maildir/.Drafts/tmp
4.0K Maildir/.Drafts/cur
20K Maildir/.Drafts
4.0K Maildir/.INBOX.Thermen/new
4.0K Maildir/.INBOX.Thermen/tmp
672K Maildir/.INBOX.Thermen/cur
692K Maildir/.INBOX.Thermen
4.0K Maildir/.INBOX.Sent/new
4.0K Maildir/.INBOX.Sent/tmp
556K Maildir/.INBOX.Sent/cur
576K Maildir/.INBOX.Sent
4.0K Maildir/.Archives.2010/new
4.0K Maildir/.Archives.2010/tmp
12M Maildir/.Archives.2010/cur
12M Maildir/.Archives.2010
4.0K Maildir/.Archives.2013/new
4.0K Maildir/.Archives.2013/tmp
38M Maildir/.Archives.2013/cur
38M Maildir/.Archives.2013
4.0K Maildir/.INBOX.Marktplaats/new
4.0K Maildir/.INBOX.Marktplaats/tmp
13M Maildir/.INBOX.Marktplaats/cur
13M Maildir/.INBOX.Marktplaats
4.0K Maildir/.INBOX.Facebook/new
4.0K Maildir/.INBOX.Facebook/tmp
322M Maildir/.INBOX.Facebook/cur
324M Maildir/.INBOX.Facebook
4.0K Maildir/.INBOX.Trash/new
4.0K Maildir/.INBOX.Trash/tmp
4.0K Maildir/.INBOX.Trash/cur
24K Maildir/.INBOX.Trash
etc.
That's right...Am I correct the script only compresses files in the ./cur directory and not all other directories?
You can't without modify the script... it checks if you provide a path ending with /Maildir, and all folders inside your maildir folder doesn't contain that but just cur folder.So there are many more folders next to ./cur, but they're not being compressed. Am I expecting the wrong result or should I compress every folder separately?
find . -regextype egrep -regex '.*/(cur|new)' -print0 | while read -d $'\0' directory; do {
Why not to just use@Dannik , @lordlex
I also started to use this script a few weeks ago and had some info from here
But indeed experiencing the same like you.
I'm busy to find out if I can make it better.
The first loop I want to change already to something like:
Like this I want to find all the cur and new folders.Code:find . -regextype egrep -regex '.*/(cur|new)' -print0 | while read -d $'\0' directory; do {
If you change the script already on that line, I'm experiencing for the moment issues when the folder name has a space in it.
And something else I think I saw is that all emails are set to read state.
Once I make some progress I will share it.
./dovecot_compress.sh all
? Uhm I'm currently not looking at compressing all configured email addresses but I'm looking at having the email items *also in the (sub) folders*?Why not to just use./dovecot_compress.sh all
?
It's compressing all the mails in all the folders.Uhm I'm currently not looking at compressing all configured email addresses but I'm looking at having the email items *also in the (sub) folders*?
@smtalk if I'm correct this shell is only compressing the emails in the real inbox folder, and as an example not the Trash folder?
#VERSION=0.0.2
# This script is written by Martynas Bendorius and DirectAdmin
# It is used to gzip all emails in Maildir directory
# Official DirectAdmin webpage: http://www.directadmin.com
# Usage:
# ./dovecot_compress.sh </home/user/imap/domains/domain.com/email/Maildir>
/usr/local/directadmin/scripts/dovecot_compress.sh all
# ./dovecot_compress.sh
Usage:
./dovecot_compress.sh /home/user/imap/domains/domain.com/email/Maildir
or
./dovecot_compress.sh all
you gave #0: ./dovecot_compress.sh
if [ $# -lt 1 ]; then
echo "Usage:";
echo "$0 /home/user/imap/domains/domain.com/email/Maildir";
echo "you gave #$#: $0 $1";
exit 0;
fi
[root@beta Maildir]# /usr/local/directadmin/scripts/dovecot_compress.sh
Usage:
/usr/local/directadmin/scripts/dovecot_compress.sh /home/user/imap/domains/domain.com/email/Maildir
you gave #0: /usr/local/directadmin/scripts/dovecot_compress.sh
I'm not yet that much further yet but to give an update:It's compressing all the mails in all the folders.
dovecot_compress.sh
(v0.0.3) is not compressing "all" the folders as I was expecting.dovecot_compress.sh
, on the right when it finished.dovecot_compress.sh
@wavoe I think so too It wasn't "all" option, was it? If not, you just compressed the mail folder you specified, and it worked as intended.If I'm not mistaking you forgot the all option, like smtalk mentioned...? However I'm still not sure if this works the selected mailbox or al mailboxes on the server. Haven't had any time to figure that out myself ?
A part of the@wavoe I think so too It wasn't "all" option, was it? If not, you just compressed the mail folder you specified, and it worked as intended.
dovecot_compress.sh
:if [ "${1}" = "all" ]; then
cat /etc/virtual/*/passwd | cut -d: -f6 | sort | uniq | while read line; do {
doCompressMaildir "${line}/Maildir"
}
done
else
doCompressMaildir "${1}"
fi
cat /etc/virtual/*/passwd | cut -d: -f6 | sort | uniq
...
/home/testemail1/imap/testemail1.com/info
/home/testemail2/imap/testemail2.com/info
/home/testemail3/imap/testemail3.com/info
/home/testemail4/imap/testemail4.com/info
/home/testemail5/imap/testemail5.com/info
...
A part of thedovecot_compress.sh
:
Bash:if [ "${1}" = "all" ]; then cat /etc/virtual/*/passwd | cut -d: -f6 | sort | uniq | while read line; do { doCompressMaildir "${line}/Maildir" } done else doCompressMaildir "${1}" fi
For me this means that using "all" option will compress all email accounts that exists on the server.
And it's just like I'm doing manually, placing the location of the Maildir folder.
Meaning that I come back on the issue what I mentioned earlier.
And just an example of the output ofcat /etc/virtual/*/passwd | cut -d: -f6 | sort | uniq
This is not what I want (yet), I just want to be sure that every email folder is getting compressed.Code:... /home/testemail1/imap/testemail1.com/info /home/testemail2/imap/testemail2.com/info /home/testemail3/imap/testemail3.com/info /home/testemail4/imap/testemail4.com/info /home/testemail5/imap/testemail5.com/info ...
Hope someone can confirm what I describe here as I have mixed feelings as it's not the first time that I try to explain this.
wget -O /usr/local/directadmin/scripts/dovecot_compress.sh https://custombuild.eu/dovecot_compress.sh