How I automated my email backup
Some time ago I bemoaned the lack of a way to have my computer run an automated back up of my IMAP email. To summarise, I had a couple of point and click methods to back up my email. Although, these were both manual methods, which means I needed to remember. No matter how good my intentions, sometimes I’ll forget, so I wanted something I could automate. This naturally lead to me wanting something that would run on the command line, which I could hence run from a script.
I’m glad to say I finally discovered a Python program called OfflineIMAP that would do just this. It won’t run on Windows, but it will run on any POSIX type operating system, i.e. Linux, FreeBSD, and Max OS. My only complaint with the thing is that if you run it manually in a terminal, you can no longer type anything into that terminal – you have to shut down and re-open the terminal window. Also, if you want to run this without having to input your log-in details (i.e. unattended executions) then you have to have them stored in a clear-text configuration file.
Other than these niggles, it is perfect for my needs. I can run it from my cron scheduler, and it synchronises with my IMAP server. This is actually better than I wanted, as synchronisation means I can use this to upload any messages I’ve archived away from the server, but want to restore.
If you’re interested in trying this, I’ll just mention that I don’t directly call it from a cronojb, but I call it from a script, because of the above mentioned terminal bug. (And no, running it like this from the cron scheduler didn’t work, it had to be ran from a script).