25

Which Linux tools help to backup and restore a IMAP mail account including all mail and subfolders?

I expect disconnects for large IMAP accounts because of

  1. ressource limitiations on the server
  2. risk of an interruption increases with the duration.

The software should be able to reconnect and continue the job after any interruption. For repeating backups it might be very handy to use incremental backups and to run the backup script in a cron job.

6 Answers 6

10

A 7 year old question, which I've searched for now, and there are a few answers, most of are spot on. But I feel at least one is missing, and there is probably room for more:

Timeline of answers:

My research led me to these additional options:

The packages below are available on Debian 11 (bullseye), but I don't know much about them yet:

  • imapcopy
    Unmainted since ~2009
  • interimap
    Still actively maintained at developer's website
  • mailsync
    On SourceForge
  • mswatch
    repo. Requires something to do the actual syncing.
  • vdirsyncer
    site. Companion to other IMAP synchers, for syncing Calendar and Contacts.

Update 2022-05

Specifically for Gmail / Google Workspace mailboxes*:
* Not an IMAP solution, but might be related to somebody's search, so I feel it's worth mentioning

As I learn more I'll update this, as I'm actively looking for a solution myself.

7

Try to use open source project imap-backup: https://github.com/joeyates/imap-backup

$ imap-backup setup

The setup system is a menu-driven command line application.

It creates ~/.imap-backup directory and configuration file. E.g.:

{
  "accounts":
  [
    {
      "username": "[email protected]",
      "password": "secret",
      "local_path": "/path/to/backup/root",
      "folders":
        [
          {"name": "[Gmail]/All Mail"},
          {"name": "my_folder"}
        ]
    }
  ]
}

It connects to GMail by default, but you can also specify a server:

{
  "accounts":
  [
    {
      "username": "[email protected]",
      "password": "secret",
      "server": "my.imap.example.com",
      "local_path": "/path/to/backup/root",
      "folders":
        [
          {"name": "[Gmail]/All Mail"},
          {"name": "my_folder"}
        ]
    }
  ]
}
3
  • At least describe how how to use to tool and describe whether it accomodates the OP's expected hardships.
    – Jeff Schaller
    Commented Aug 17, 2017 at 22:35
  • I edited my post.
    – Quarind
    Commented Aug 18, 2017 at 9:05
  • This is by far the best tool I've met on my years long search for a solid imap backup tool!
    – Max Power
    Commented Aug 15, 2023 at 0:18
4

OfflineIMAP is a GPLv2 software to dispose your mailbox(es) as a local Maildir(s).

For example, this allows reading the mails while offline without the need for your mail reader (MUA) to support disconnected operations.

OfflineIMAP will synchronize both sides via IMAP.

http://www.offlineimap.org/

https://github.com/OfflineIMAP/offlineimap

It also supports restoring to an IMAP server: http://www.offlineimap.org/doc/backups-restore.html

3

You can use imapsync for this. You can get the source from fedorahosted.org imapsync page. Zimbra Guide to imapsync has good documentation about this subject.

-1

More to do with backing up than your questions but I've just found and started testing mailpiler. Not sure I like the fact of giving access to "all" email so working out how to send "older" email on regular basis to file there.

At the moment we use Awesome Auto Archive thunderbird extensions to "move" emails to another filing account.

1
  • mailpiler seems to be a commercial web service where you can send all your mails to. Besides obvious security concerns this is not what was asked for in this question. Commented Dec 27, 2018 at 21:58
-4

"cp -pr" should do the job. The "r" option in "pr" should take care of both subfolders and any hidden files/directories.

1
  • 4
    I guess this answer assumes the mails are in a Maildir type format in which case any tool to copy the files should work, and rsync might be a good option. But I think OP is interested in a solution that connects remotely through IMAP.
    – Mehmet
    Commented Dec 14, 2014 at 21:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .