Maildir auto-archive

GPLv3
If you’ve got your mail sitting on some server and in Maildir format, and you’ve used Outlook’s “Auto Archive” feature, you might wish that your inbox (and subdirectory contents) could be automatically swept clean of items older than, say, 3 weeks, and shoved into a Year/Quarter sub folder (like “Inbox/2008/Q1/”).

A couple years ago I wanted this too. So I wrote a cronjob and perl script to make this happen.

Installation is straightforward:

  1. Copy the shell script that cron calls, autoarchive, and the perl script, autoarchive.pl, onto the server holding your Maildir.
  2. Edit the autoarchive shellscript to make sure the path and –max-days is ok with you.
  3. Make both scripts executable with chmod u+x
  4. Make a backup of your mail. This is GPL code. No warranty is implied. Read the code and try it out with –dry-run first.
  5. Calling autoarchive.pl with the “–dry-run” option will let you make sure it’s doing what you want it to do. If it does, delete the dry-run.
  6. Wire it up to cron with something like:
    PATH=$HOME/bin:/usr/bin:/bin
    42 10 * * * autoarchive > /dev/null

Related posts:

  1. How to view only unread gmail conversations
    Gmail doesn’t have an obvious way to only look at conversations that are unread. If you don’t “archive” conversations out of your inbox, it can get pretty crufty. It’s easy......
  2. Verifying file integrity with debsums
    After upgrading my Ubuntu server, some security applications grumped about changed contents of some common binaries. Just to be safe, I wanted to verify them explicitly with debsums, but debsums......
  3. Randomly sort the lines in a file
    There are times when you need to randomly order the lines in a file. Here’s a script to do just that: #!/usr/bin/perl -w use strict; use List::Util 'shuffle'; my @lines......
  4. Simple MySQL backup to gmail on Ubuntu/Debian
    Backing up your MySQL database (if it’s a reasonable size, like < 100s of MB) can be done with a cronjob that runs mysqldump, gzip, and mpack. First set up......

This entry was posted in Technical HOWTOs and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Additional comments powered by BackType