And my email configuration addiction continues. As you may recall, I did an extensive (now out-dated) post about my email setup. I’m still using the basic configuration outlined there (all of the same programs) just some of my settings have changed a little. I tend to make little changes every now and then which I think will save me a tiny amount of time wet-ware processing my email. Below I outline how I am making the transition to new machines/installs easier for my email setup.
Restore Config Files
With the purchase of a new laptop, I have to re-setup my email’s (and other applications’) configuration. Luckily, I keep all of my configuration files in version control which is synced between 3 computers; my old laptop, my desktop, and my webserver (for mostly backup purposes, but also for imapfilter). All I had to do was run the following very basic commands:
mkdir src
cd src
bzr branch greg@my.server.net:/home/greg/src/dotfiles .
bzr branch greg@my.server.net:/home/greg/src/scripts .
cd scripts
./restore_email_apps.sh
./restore_symlinks_desktop.sh
The first 5 things are pretty self-explanatory: make a directory called “src,” go in there, then create 2 branches of the bzr repos for dotfiles and scripts.
Then, lets run two of the scripts in ~/src/scripts/.
restore_email_apps.sh is really just an easy way for me to remember which applications I use for email and its supported functions. The contents of that shell script is merely:
sudo aptitude install mutt-patched offlineimap msmtp abook
Yep, thats it.
The restore_symlinks_desktop.sh file is a little more involved. Basically, since I keep all of my dotfiles in a bzr repo called ~/src/dotfiles I need to tell the associated applications where to find those files. Well, I don’t really tell the applications, I trick them. I create symbolic links from where they are expecting the file to where I actually keep it. This is a common trick for these types of setups. In fact, if you didn’t want to use a traditional version control system to handle the versioning/syncing between computers you could store your dotfiles in your Ubuntu One folder and then they will be synced automatically. So, restore_symlinks_desktop.sh goes and creates all of those symlinks for me.
offlineimap
Now, you may have noticed that I use offlineimap with my email system. I won’t go into all of the benefits of offlineimap here, but the main ones that I enjoy are: local really fast storage of my mail (vs online) and brain-less email backups (its already backed up already).
However, using offlineimap creates one speed bump in this email setup; you need to redownload all of your email again, which, if you are like me and don’t delete anything (just put it in an Archive folder) then this can take a long time depending on your mail server. And, if you use gmail’s servers, they can lock you out of IMAP access if you download too much. Luckily, offlineimap is pretty robust and allows you to get around that problem fairly easily.
Note: I have only done this with offlineimap using the MailDir format so I don’t know what would be different for the other formats. Also, I haven’t seen any other guides like this online which is A) why I wrote this out and B) makes me wonder if this is bad for some reason [I did this over 5 days ago and haven't lost any email yet].
Anyway, here is what I did:
1) copy my .maildb folder from one computer which had a recent sync to my new laptop using a local LAN. I did this using rsync so it would compress during transit, because even at 10 megs a second, 6 gigs is a lot to transfer.
rsync -e 'ssh -ax' -auhvz --progress greg@192.168.1.102:/home/greg/.maildb/ /home/greg/.maildb/
2) rename the MailDir format email files to reflect the new computer’s hostname. The files look like this:
1264133355_0.24102.alexandria,U=3422,FMD5=e727b00944f81e1d0a95c12886ac4641:2,S
That “alexandria” part is the hostname of my desktop. So, I need to change that to “zen” so it looks like this:
1264133355_0.24102.zen,U=3422,FMD5=e727b00944f81e1d0a95c12886ac4641:2,S
But I need to do that for ALL of my email. find and xargs to the rescue!
find . -name '*' -type f -print0 | xargs -0 rename -v 's/alexandria/zen/'
3) setup offlineimap; ie: install and configure your email accounts. This is already done for me by running those two scripts above. Note: Make sure your ~/.offlineimap folder is empty (ie: don’t copy it over from your old computer).
3b) A big change from my last email setup is that I am now checking one of my mail account (grossmeier.net) over ssh. Basically, offlineimap ssh’s to the server, then runs an imap server (in my case, rimap). I followed the instructions set out here: http://eagain.net/blog/2007/02/09/imap-over-ssh.html (changing the pertinent parts about the imap service on the server, of course).
4) run offlineimap. You should see it SCREAM through your email archive as it adds the metadata to its .offlineimap folder from the local maildir you just copied to the machine.
There ya go. Now when you get a new machine and you use offlineimap to sync your email you don’t need to re-download all of your email again.