TuX as LLG logo
Software
DMX4Linux
Driver Suite for Linux
csv2iif.pl suite
convert PayPal transactions to IIF, OFX, QIF
Hardware
DMX30 Interface
128Ch SPP
DMX43 Interface
2out 2in EPP
LED Hardware
for Linux and Windows
EPROM Sampler
for 8 bits of sound
Misc
CatWeasel
Linux drivers for MK3/4 PCI
pg_trompe
PostgreSQL replication
trycatch
C exception/signal handling lib
Patches
to various software
Tools
and small scripts
Docs
misc documents
Links
to lighting stuff

IMAP backup with fetchmail

I am using IMAP to access all my mail boxes. However beeing afraid of data-loss I would like to make a regular backup of my IMAP mailboxes, without accessing the physical files in the IMAP server, since I don't have a shell account for all my mail accounts. I'm describing how to use fetchmail and the formail program from procmail to download all your IMAP folders into a local mbox style file.

Use the following fetchmail configuration as a template. Replace all USERNAME with your unix user account name, all PASSWORD with the password for that IMAP account, all IMAPUSER with the IMAP username, all MAILHOST with the IMAP serverhostname and finally all MBOXPATH your mbox (absolute) filenames.

set postmaster "USERNAME"
set bouncemail
set no spambounce
set softbounce
set properties ""
set no showdots

poll MAILHOST with proto IMAP
  user 'IMAPUSER' there with password 'PASSWORD' is 'USERNAME' here
  options keep fetchall ssl mda "formail -c >> /MBOXPATH/inbox"
  folder INBOX

poll MAILHOST with proto IMAP
  user 'IMAPUSER' there with password 'PASSWORD' is 'USERNAME' here
  options keep fetchall ssl mda "formail -c >> /MBOXPATH/sent"
  folder INBOX.Sent

It should be obvious that I'm fetching each IMAP folder into a separate mbox onto my local machine by a poll directive for fetchmail. You can fetch multiple folders with one poll if you set multiple folder names separated with commas in the folder line. All mail from all folders would end up in the same mbox. See fetchmail(1) for details.

Your IMAP folder names/paths may be different from the one shown here, this configuration works with Courier-IMAP. We use a custom mail delivery agent (mda) for fetchmail, which is the formail(1) program. formail converts any emails downloaded by fetchmail into the mbox format and they are simply appended onto a local file. If you run fetchmail twice, you would have all emails twice in that file, so you should create a simple shell script to delete your local mbox files before running fetchmail.

See Also

The program getmail can probably be used to create backups as well, but I haven't tested it.

Contact

Write an email to Dirk Jagdmann for questions and suggestions.


Search:
http://llg.cubic.org © 2001-2017 by Dirk Jagdmann