2

I'm trying to setup a new mail server for my personal use, and I want to do it better than all the prior times.

One thing that has always concerned me is backing up my inbox and other folders. In the past, I've used POP3 with Mozilla App Suite / SeaMonkey as my client, and always found it problematic to do backups, since partial backups were very problematic (short of storing the messages based on a year, and renaming and moving stuff around (and then never moving them around again), which is difficult to script on Windows anyways, and limits you to yearly backups, which get annoying to do). Also, the setup was tied to a single PC, another thing I want to avoid.

I'm now thinking of going with Dovecot IMAP4, and backing up mbox and other folders on the server with git, on a weekly, daily, hourly or per-message basis.

With git and several mbox files (mail folders), if an email moves from one mbox to another (e.g. arrives in Inbox, then gets moved to a folder), will git find out all such cases of various emails moving to various folders?

Does backing up imap mbox files with git sound feasible? Practical? Is it a good idea at all? Will it work, and will it be relatively easy to setup?

Or should I drop mbox, and go with maildir? Would git be better with maildir at all?

cnst
  • 2,615

2 Answers2

0

I'm not aware of anyone using git for backups of mailboxes/maildirs...

I'm using local rsync into another folder to make backups, i guess the git versioning would only make a mess on the destination folder.

Go with Dovecot and IMAPv4 along with Maildir in home directory to store your mails, it's faster in most scenarios and you will save yourself from possible locking issues.

0

I back up my remote IMAP mails in a local Maildir directory which is version-controlled by git. It's a bit geeky and hackish, but I think it's a good way if you don't want to lose any emails and want to be safe even if you accidentally delete a bunch of mails on your remote IMAP. The script which does the job works the following way:

  • All remote mails on the IMAP server are synchronized with a local Maildir directory. I use imapsync for this.
  • The mail files in this local Maildir are then copied to a version controlled git-Maildir directory. The original directory structure is not retained, as this is not important to me. Instead, the git-Maildir contains a folder for every year and the mail files are copied to the year folder based on the Date-header of the mail file. I use mu (mailbox utils) to do the sorting work.
  • In the next step, the script automatically adds and commits the new files to the git repository.

With this, I have a local backup of all my emails. Even if I delete mails on remote side, I still have local copies. The advantage of the local git repository is data safety. Even I mess with my files in my local backup, I have a full history in the commit history and I can recover deleted mails.

The advantage of maildir over mbox is, that with maildir you have one file for each mail instead of one huge mbox file which changes every time you add new mails. One file per mail makes a nice git history.

seb
  • 539