Discussion:
delete/archive old mail
sottilette
2014-10-13 11:42:23 UTC
Permalink
Hi everybody,
I store user's mail in the old mbox format.
I have many scripts to manage users that works fine with mbox.
I use the very old Expire_mail.pl script to delete mail older than NN days
for selected users (nightly cron job). Still works fine with my CentOS
dovecot-2.0.16.
Now I want move the mail to a sort of archive folder instead of
simply deleting it from the inbox for some users.
Is there a similar script or some simple triks?

Thanks, F.
Robert Schetterer
2014-10-13 11:46:56 UTC
Permalink
Post by sottilette
Hi everybody,
I store user's mail in the old mbox format.
I have many scripts to manage users that works fine with mbox.
I use the very old Expire_mail.pl script to delete mail older than NN
days for selected users (nightly cron job). Still works fine with my
CentOS dovecot-2.0.16.
Now I want move the mail to a sort of archive folder instead of simply
deleting it from the inbox for some users.
Is there a similar script or some simple triks?
Thanks, F.
perhaps you will find some ideas here

https://sys4.de/de/blog/2013/02/07/mailarchiv-mit-dovecot-und-postfix-sortiert-nach-datum-mailadressen-und-ein-ausgehend-unterordnern/

...
#/bin/bash
YEAR=`/bin/date +%Y`
/usr/bin/doveadm expunge -d -u *@backup.server.org mailbox
user-backup\*$YEAR*\* savedbefore 10d
...


Best Regards
MfG Robert Schetterer
--
[*] sys4 AG

http://sys4.de, +49 (89) 30 90 46 64
Franziskanerstra?e 15, 81669 M?nchen

Sitz der Gesellschaft: M?nchen, Amtsgericht M?nchen: HRB 199263
Vorstand: Patrick Ben Koetter, Marc Schiffbauer
Aufsichtsratsvorsitzender: Florian Kirstein
F.
2014-10-14 11:17:43 UTC
Permalink
Post by Robert Schetterer
Post by sottilette
Hi everybody,
I store user's mail in the old mbox format.
I have many scripts to manage users that works fine with mbox.
I use the very old Expire_mail.pl script to delete mail older than NN
days for selected users (nightly cron job). Still works fine with my
CentOS dovecot-2.0.16.
Now I want move the mail to a sort of archive folder instead of simply
deleting it from the inbox for some users.
Is there a similar script or some simple triks?
Thanks, F.
perhaps you will find some ideas here
https://sys4.de/de/blog/2013/02/07/mailarchiv-mit-dovecot-und-postfix-sortiert-nach-datum-mailadressen-und-ein-ausgehend-unterordnern/
...
#/bin/bash
YEAR=`/bin/date +%Y`
user-backup\*$YEAR*\* savedbefore 10d
...
Thanks for replay.
My German is really poor, but from a quick look of the example above and
man doveadm[-expunge], seems that it can be used to replace the old
Expire_mail.pl (I need to study the right syntax ...)
But still there is the move/archive old mail activity not solved.
i use the bc feature of postfix to move a copy of all mail per
maildomain into a backup maildomain archive folder, as this is done via lmtp
i am able to sort mails via sieve per user and date folder, depending
on how you like to setup you may use imap acl to give seen rights to the
orig user, so the may restore their own mail whenever they want and/or
their domain postmaster can do it for them.
But thats only one chance you can do it, you have to decide what fits
best to your needs.
doveadm-altmove seems interesting, but in the man page it is reported
only work with dbox (dbox-only), and my inboxes are in mbox format.
Any other advice?
Sorry for the replay to sender instead of the list.

As I originally wrote, my need is script or a command like the old
Expire_mail.pl that parse a local mbox folder and move/copy mail older
than NN days to another local mbox folder.
Probably for a Perl programmer is only matter of modify this script or
something similar.
I searched in docs, wiki, ... but not noticied something that can simply
be inserted in a cron job to do the work.

Only migration tools or complex (for me), library that can be used to
manipulate folders :-)

Thanks, F.
Joseph Tam
2014-10-15 00:09:13 UTC
Permalink
Post by F.
doveadm-altmove seems interesting, but in the man page it is reported
only work with dbox (dbox-only), and my inboxes are in mbox format.
Any other advice?
As I originally wrote, my need is script or a command like the old
Expire_mail.pl that parse a local mbox folder and move/copy mail older
than NN days to another local mbox folder.
Probably for a Perl programmer is only matter of modify this script or
something similar.
I searched in docs, wiki, ... but not noticied something that can simply
be inserted in a cron job to do the work.
Only migration tools or complex (for me), library that can be used to
manipulate folders :-)
I don't understand how you could have found doveadm-altmove, but miss
doveadm-move -- doesn't this dovecot command do exactly what you want?

$ man doveadm-move

NAME
doveadm-move - Move messages matching the given search query
into another mailbox
...

EXAMPLE
Move janes messages - received in September 2011 - from her
INBOX into her archive.

doveadm move -u jane Archive/2011/09 mailbox
2011-10-01 SINCE 01-Sep-2011

[Is this a typo: "2011-10-01" should be "INBOX"?]

The example is fairly close to what you want. Apart from the obvious change
to user and mailbox name, the condition would be "savedbefore ${NN}d". You
might have to follow this up with an expunge if this operation does not
do that.

Joseph Tam <jtam.home at gmail.com>
Pascal Volk
2014-10-15 19:37:04 UTC
Permalink
Post by Joseph Tam
...
EXAMPLE
Move janes messages - received in September 2011 - from her
INBOX into her archive.
doveadm move -u jane Archive/2011/09 mailbox
2011-10-01 SINCE 01-Sep-2011
[Is this a typo: "2011-10-01" should be "INBOX"?]
?
Where did you find this example?

,--[ doveadm-move(1) 2013-11-23 ]--
| EXAMPLE
| Move jane's messages - received in September 2011 - from her INBOX into
| her archive.
|
| doveadm move -u jane Archive/2011/09 mailbox INBOX BEFORE \
| 2011-10-01 SINCE 01-Sep-2011
`--

Also http://wiki2.dovecot.org/Tools/Doveadm/Move#section_example
shows the correct example.


Regards,
Pascal
--
The trapper recommends today: cafefeed.1428821 at localdomain.org
Loading...