Hacker News new | ask | show | jobs
by seifferth 1671 days ago
While I don't know of any imap to git sync tool specifically, there are tons of tools for storing email locally in plain text and for keeping these local email stores in sync with imap servers. The most common local email store formats seem to be mbox[1] and maildir[2]. Mbox stores one "folder" of emails per file, while maildir stores one email per file, which does seem to be the more modern approach (exceeding your file quota does not seem to be a particularly urgent problem anymore).

I personally use mbsync[3] to pull my email into a local maildir. I also use notmuch[4] and a nice tui[5] to search, read and write it. Note that filenames in maildir are unique, but provide little value beyond that. Some emails are also encoded in ways that will hide content from grep and friends (base64 being among the most popular ones). This makes notmuch especially valuable, as it abstracts all those encoding issues away and provides an amazing search interface.

I do not use a git repository for email myself, yet since a maildir is just a directory tree of plain text files, storing it in a repo is a no-brainer:

    mbsync -a      # Configured via dotfiles
    cd my_local_maildir
    git add .
    git commit
[1]: https://en.wikipedia.org/wiki/Mbox

[2]: https://en.wikipedia.org/wiki/Maildir

[3]: https://isync.sourceforge.io/

[4]: https://notmuchmail.org/

[5]: https://github.com/wangp/bower

1 comments

I solved my email problem recently, and I will probably clean it up and put it on Github.

I have a Dovecot Docker container that I spin up and mirror my imap emails with imapsync. You can easily configure imapsync to use a friendly mapping for the imap layouts of different providers (they have good documentation with examples)

Git worked pretty well for storage of the dovecot emails, but then I got even more sophisticated.

I now use a bup repo inside a git-annex repo[1]. This is because I get the benefit of being able to track which computer I have backups on, and the myriad of git-annex backends[2], while bup provides compression, reduplication, and par2 error correction data.

[1]: https://git-annex.branchable.com/tips/Bup_repositories_in_gi... [2]: https://git-annex.branchable.com/todo/external_backends/