[Dovecot] Thunderbird Archive to slower storage - sort of alternate storage
Hi people,
When a user archives a message from Thunderbird it moves to an IMAP folder "Archives", everyone knows that. I use dovecot 1:1.2.9-1ubuntu6.5 on Ubuntu 10.04 and want to move that folder (and respective IMAP sub-folders) to a slower storage, link it to original location and my first idea for this is
find -type d -name .Archives\* -print0 |
while read -d $'\0' archive; do
mv "$archive" /dead/Emails/jhon.doe/;
ln -s "/dead/Emails/jhon.doe/$archive" .; done
It works, given that the files are not locked. I could restart dovecot before so it would unlock the files, but there is no guarantee it does not get locked again before the find finishes.
I took a look on mailling list archives, but could not find something like that and was wondering what you guys use (if any) for such task and what are the recommendations, best practices, solutions for that?
Thanks in advance, best regards.
-- *Marcio Merlone*
On 13.3.2012, at 16.36, Marcio Merlone wrote:
Hi people,
When a user archives a message from Thunderbird it moves to an IMAP folder "Archives", everyone knows that. I use dovecot 1:1.2.9-1ubuntu6.5 on Ubuntu 10.04 and want to move that folder (and respective IMAP sub-folders) to a slower storage, link it to original location and my first idea for this is
find -type d -name .Archives\* -print0 |
while read -d $'\0' archive; do
mv "$archive" /dead/Emails/jhon.doe/;
ln -s "/dead/Emails/jhon.doe/$archive" .; doneIt works, given that the files are not locked. I could restart dovecot before so it would unlock the files, but there is no guarantee it does not get locked again before the find finishes.
I'm not sure what you mean by locks. dovecot-uidlist.lock? Anyway, the above is safe only if the IMAP client doesn't try to access the mailboxes during the move. Otherwise it can become confused.
I took a look on mailling list archives, but could not find something like that and was wondering what you guys use (if any) for such task and what are the recommendations, best practices, solutions for that?
A perfectly working solution would be to (upgrade to v2.x and) switch to sdbox or mdbox format with alt storage enabled, then you could simply do:
doveadm altmove -A mailbox 'Archives*' all
Em 13-03-2012 13:49, Timo Sirainen escreveu:
On 13.3.2012, at 16.36, Marcio Merlone wrote:
It works, given that the files are not locked. I could restart dovecot before so it would unlock the files, but there is no guarantee it does not get locked again before the find finishes. I'm not sure what you mean by locks. Operating system lock of open files (lsof).
A perfectly working solution would be to (upgrade to v2.x and) switch to sdbox or mdbox format with alt storage enabled, then you could simply do: doveadm altmove -A mailbox 'Archives*' all Sounds really nice. There are no 2.0 packages for Lucid tough, so will take a look at the latest stable Ubuntu, or perhaps give the beta a try (until it comes stable).
Thanks for your prompt reply. :)
-- *Marcio Merlone*
Em 13-03-2012 15:58, Marcio Merlone escreveu:
Em 13-03-2012 13:49, Timo Sirainen escreveu:
A perfectly working solution would be to (upgrade to v2.x and) switch to sdbox or mdbox format with alt storage enabled, then you could simply do: doveadm altmove -A mailbox 'Archives*' all Should this command be run every time a new folder (.Archives.2012 for example) is created or can this be automated, something like instructing deliver to do this to any Archives* is created? In other words, to cron or not to cron?
Best regards.
-- *Marcio Merlone*
On Wed, 2012-03-14 at 08:51 -0300, Marcio Merlone wrote:
Em 13-03-2012 15:58, Marcio Merlone escreveu:
Em 13-03-2012 13:49, Timo Sirainen escreveu:
A perfectly working solution would be to (upgrade to v2.x and) switch to sdbox or mdbox format with alt storage enabled, then you could simply do: doveadm altmove -A mailbox 'Archives*' all Should this command be run every time a new folder (.Archives.2012 for example) is created or can this be automated, something like instructing deliver to do this to any Archives* is created? In other words, to cron or not to cron?
It's not deliver that creates it, it's the IMAP client. And it would have to be done when IMAP client copies mails there. But there's currently no easy way to automate that, so you'd need to do it in cron.
Another possibility could be to add a new feature (plugin) that always immediately saves mails in Archives* mailboxes to alt storage.
Em 14-03-2012 09:19, Timo Sirainen escreveu:
On Wed, 2012-03-14 at 08:51 -0300, Marcio Merlone wrote:
Em 13-03-2012 15:58, Marcio Merlone escreveu:
Em 13-03-2012 13:49, Timo Sirainen escreveu:
A perfectly working solution would be to (upgrade to v2.x and) switch to sdbox or mdbox format with alt storage enabled, then you could simply do: doveadm altmove -A mailbox 'Archives*' all Should this command be run every time a new folder (.Archives.2012 for example) is created or can this be automated, something like instructing deliver to do this to any Archives* is created? In other words, to cron or not to cron? It's not deliver that creates it, it's the IMAP client. And it would I first though about deliver since this seems the guy who could do that, but don't matter.
have to be done when IMAP client copies mails there. But there's currently no easy way to automate that, so you'd need to do it in cron. Just imagine that:
protocol imap{ ... x_alternate_storage_always = Archives, Spam, Trash x_alternate_storage_size = 20MB x_alternate_storage_age = 1y ... }
The client (Thunderbird?) sends imap commands to dovecot create such folder or to move a message to such folder. Dovecot obeys and check the config to see if the folder in question is one of those listed on x_alternate_storage_always. If the folder is not on alternate storage yet, create/move it there and them proceed what was asked to do.
I imagine that an age based action would depend of a cron job in order to not overload the server each time it performs any imap command and check old messages age...
Another possibility could be to add a new feature (plugin) that always immediately saves mails in Archives* mailboxes to alt storage. I don't know if the duck is male, I want the egg! :)
I know nothing about the inner workings of dovecot, and very little about the outer working. A well designed and integrated plugin could be, but seems to be a nice core feature for dovecot, based on folder name, size or age.
Many thanks for your time. Please be kind considering those ideas, I am just a poor man's server admin. :)
Best regards.
-- *Marcio Merlone*
participants (2)
-
Marcio Merlone
-
Timo Sirainen