Spotlight | Reviews | Current Issue | Academy | Newsletter | Subscribe | Shop |
Departments

Partner Links
Make your own website
WinWeb OnlineOffice
Comparing prices of hardware is worth it.
Price Comparison
What:
Where:
Country:
vacatures Netherlands njobs Linux vacatures
arbeit Deutschland njobs Linux arbeit
work United Kingdom njobs Linux jobs
Lavoro Italia njobs Linux lavoro
Emploi France njobs Linux emploi
trabajo Espana njobs Linux trabajo

user friendly

Admin Magazine

ADMIN Network & Security

Subscribe now and save!

 ADMIN - Explore the new world of system administration! ADMIN is a smart, technical magazine for IT pros on heterogeneous networks. Each issue delivers technical solutions to the real-world problems you face every day. Learn the latest techniques for better:

  • network security
  • system management
  • troubleshooting
  • performance tuning
  • virtualization
  • cloud computing

 on Windows, Linux, Solaris, and popular varieties of Unix.

http://www.admin-magazine.com/

  linux-magazine.com » Online » Blogs » Productivity Sauce » Back up Email with a Single Command  

Productivity Sauce
Productivity Sauce

Back up Email with a Single Command

The Web is awash with tutorials on how to back up your email. Strangely, none of them covers probably the easiest and most efficient email backup system based on the excellent IMAP Grab utility. This tiny Python script acts as a user-friendly wrapper for the getmail tool. Using the script, you can set up a fool-proof email backup solution using just a single command.

Deploying the IMAP Grab backup solution is a cinch. First off, install the getmail package using your distro's package manager. Download then the latest IMAP Grab package, unzip it, and move the imapgrab.py file to the directory of your choosing. Make the script executable using the chmod +x imapgrab.py command.

To make sure that the script works properly and to obtain a list of the available mailboxes, run the following command in the terminal:

./imapgrab.py -l -s imap.mail.server -u username -p password

Replace imap.mail.server, username, and password with the actual mail server address and your login credentials. The -l (or --list) argument instructs the script to fetch a list of IMAP folders on the specified email account. If everything works as it should, the command should return a list of the available mailboxes.

Now you can construct a command to back up emails. It may look something like tihs:

./imapgrab.py -d -v -M -f /home/user/emailbackup -s imap.mail.server -u username -p password -m "_ALL_,-INBOX.Trash,-INBOX.Junk Mail"

The -d (--download) argument instructs the script to download messages, while the -f (--folder) argument specifies the destination directory. By default, the script downloads emails in the Mbox format which stores all messages in a single file. However, IMAP Grab supports the Maildir format, too, and you can force the script to use this format by adding the -M (--maildir) argument.

IMAP can also handle SSL connections, and you can use the -S (--ssl) and -p (--port) arguments to enable this feature:

./imapgrab.py -l -s imap.mail.server -S -p 993  -u username -p password

The -m (--mailboxes) argument lets you specify which IMAP folders you want the script to back up. The _ALL_ switch instructs the script to download all the available folders. To exclude certain folders from the backup, use the minus (-) character followed by the name of the mailbox you want the script to omit. So the -m "_ALL_,-INBOX.Trash,-INBOX.Junk Mail" argument instructs the script to download all folders except INBOX.Trash and INBOX.Junk Mail.

Finally, when you run the script for the first time, you might want to add the -a (-all) argument which forces IMAP Grab to download all messages.

That's all there is to it. To perform backup on a regular basis, set up a cron job, and you are done.

Comments

This is the main site

goll Sep 14, 2011 8:34pm GMT

http://sourceforge.net/projects/imapgrab/

Download

Interested Mar 07, 2011 3:50pm GMT

Can't seem to download at all today, even mirrors don't seem to work.

Restore

ue Mar 06, 2011 11:53pm GMT

Backup is not very useful unless there also is a restore. If the server goes up in flames you would probably want your mail back on the server so that it was searchabe, forwardable,... This article doen't mention how this is done.

small mistake

Pepa Mar 05, 2011 3:50am GMT

The Port option is -P (a capital P).

IMAP Grab GUI

Roger Mar 04, 2011 9:32am GMT

Worth mentioning that IMAP Grab bundles a simple GUI with Gmail presets. It's great work...

Print this page. Recommend
Share