Blog

imapsync is a well-known tool for migrating e-mail boxes from one server to another. I’ve been using imapsync for many years and over at bytemine it is our tool of choice for this job.

Aside from general praise of imapsync, I want to show couple of nice options for archiving stuff. I use the passfile1 and passfile2 options, so that I don’t have the passwords displayed in the process listings.

Q: Move all messages from the year 2010 from one gigantic Sent-folder to an archive folder specific for that year:

imapsync --host1 source-imap-server --user1 user-at-source-server --passfile1 passfile1 --host2 dest-imap-server --user2 user-at-dest-imap-server --passfile2 passfile2 --folder "INBOX/Sent-Archive-folder-all" --search "SENTSINCE 1-Jan-2010 SENTBEFORE 31-Dec-2010" --regextrans2 's/Sent-Archive-folder-all/Sent-Archive\/2010/' --sep1 / --sep2 / --dry

Once you’re sure it does, what you want, remove the dry from the command line.

Q: Move all messages from one server to an archive folder on another server whilst ignoring certain folders (see --exclude Option)

imapsync --host1 source-imap-server --user1 user-at-source-server --passfile1 passfile1 --host2 dest-imap-server --user2 user-at-dest-imap-server --passfile2 passfile2 --exclude ^Gesendete Objekte$ --exclude ^INBOX/Sent-Archive* --sep1 / --sep2 / --subfolder2 INBOX/archive