Copying/Migrating email via IMAP using larch

For a couple of years, I have forwarded all my email to my gmail account. This has been quite convenient. However, this has also resulted in workflow issues, or plainly put, me checking and replying to work related email messages when not working and vice versa.

So, I decided to separate my email accounts again. I have during these years, set up a number of labels etc in gmail that I wish to preserve.

After dragging and dropping email messages for a while, I started looking into how to automate this task. I have ended up using larch which works great. I create a config file where I enter all my details (source and target servers, source and target folders, folders to exclude, etc). larch can be used to recusively sync a specified folder tree which is the option I went for. It also automatically retries if there is a glitch.