Open a terminal and go to the imapsync directory.
The imapsync directory is the directory created by extraction
of the tarball (.tgz), its name is
is imapsync release number (1.882 at the time of this writing).
Verify imapsync runs on your system
It should output the help message.
If the previous command fails then there is an installation issue. Go back to https://imapsync.lamiral.info/#install then and read and apply the installation file corresponding to your system and drop me an email about your issue.
Next, verify imapsync runs live tests. This check needs an Internet access. It does a simple sync between two real dedicated imap maiboxes located at the host test.lamiral.info
Now verify that the script examples/imapsync_example.sh runs fine:
This script does the same thing than "
imapsync --testslive" but it
uses explicitly the 6 parameters so it will be a good start
for your future own script.
I consider you're still in the imapsync top directory.
Make a copy of the script
cp examples/imapsync_example.sh mysync
Check that the copy works as the original
So far so good, now we're going to work with your data.
An IMAP account is accessed with 3 parameters,
Since imapsync job is to sync two imap accounts we need 3 + 3 = 6 parameters:
Even during the learning time with imapsync, you can take a real user account as a source. There is also no problem if this account is currently used by a user. By default, this account will only be read, no change will be made by imapsync on it.
Assuming that the imap source server name host1 is origin.example.com, the user1 account name is myuser1 and its password is mysecret1, we now have the first three parameters.
Unlike the source side, the destination side will be modified by imapsync. Therefore, for learning, checking and adjusting, it is not a very good idea to use a real user imap account the first times you play with imapsync.
If you really can't afford a test account on host2, it's ok, imapsync is not that bad but you may have some work to do to fix some unwanted behavior. Unwanted behavior is mostly folders names that you don't want to be the same on both sides.
Assuming that the imap destination server name host2 is destiny.example.com, the user2 account name is myuser2 and its password is mysecret2, we now have the next three parameters.
Now edit the script
mysync and replace the test values by yours.
You're ready for a dry test on your accounts.
mysync script is a copy of
your first run with your data should include three other options
--dry option, nothing will really be done on host2
but yet it will test whether the credentials are ok on both sides.
You'll encounter two successful logins, or one failure on host1,
or a successful login on host1 but a failure on host2.
If the login are ok, you will also observe if the folders mapping is ok.
If a login fails then double-check all three values that identify the account, which are the host, the login name, and the password.
If the folders mapping proposed is not ok then you can fix it with
--f1f2. The following example maps the source folder
"Sent Messages" to the destination folder "Sent". The double-quotes
are not part of the folders names but they should be used when special
characters like blanks are in the folders names:
./imapsync ... --f1f2 "Sent Messages=Sent"
As explained in the inline help or in the README:
--f1f2 str1=str2 : Force folder str1 to be synced to str2.
You're ready for a real test on your accounts, restricted to
--dry from the
mysync script and rerun
Three Internet protocols are used to access almost all email accounts: POP3, IMAP, HTTP.
The oldest protocol still used to access mailboxes is POP3, the Post Office Protocol. POP3 gives access to only one main box called INBOX.
With POP3, messages have no flags at all, no Seen/UnSeen, Forwarded, or Flagged labels.
It's not systematic but messages are often removed from a POP3 server each time a software client looks into it, so messages only appear on the client host that fetched them, they are unavailable from any other system located elsewhere.
The second protocol to deal with email messages is IMAP, Internet Message Access Protocol. IMAP gives access to a hierarchy of mailboxes also called folders. Other IMAP features are concurrent accesses, tagging with flags, search by many criterium like date, subject, size etc.
The IMAP protocol presents most of the features POP lacks. Messages stay on the imap server so any client on the network can access them at any time from anywhere, the same messages with the same flags.
The third protocol to access email messages is HTTP, HyperText Transfer Protocol. HTTP is the protocol to browse the web.
Web browsers like Google Chrome, Mozilla Firefox, Internet Explorer and Safari are HTTP client software tools. You already know that so what's the point with HTTP mailboxes? HTTP mailboxes are called webmails. Webmails often offer the same features than imap servers because webmails underlying storage systems are often imap servers.
Webmails systems like Gmail, Yahoo, Exchange, Zimbra or Office365 are also accessible via imap.
The conclusion of this protocol review is that mailboxes can be accessed using the IMAP protocol, most of the time. Here comes imapsync.
In case the source mailbox is only accessible by the POP protocol,
you can use the tool
pop2imap to sync them.
pop2imap is located at http://www.linux-france.org/prj/pop2imap/
Software imapsync is a command line tool to copy, migrate, backup or synchronize IMAP mailboxes.
Command line means imapsync is not graphical, it is textual. Usually with command line tools you have to type characters on your keyboard. But your fingers won't suffer much pain typing on the keyboard because script examples are given, nearly ready to run. Most of the time you only have to change the main values in those files and adapt them to your context.
Don't be afraid, the mouse won't be forsaken. You can still use the mouse to launch an editor, select/copy/paste complete examples, and run the little script with a double-click.
Imapsync runs on Linux, Windows and OS X (Macintosh world). Imapsync is written in the Perl language and, thanks to the Perl developers, Perl runs mostly everywhere. So does imapsync.
While operating systems have a lot in common, they sometimes differ, especially within their syntax. I won't blame anyone, historically Windows came after Unix. The marvelous designers in this old times decided it would be very cool to not share exactly the same syntax for doing the same things.
To designate an end of line, Unix uses the character \n Windows uses two characters \r\n and Mac use \r. Thanks guys, great great thinking! Fifty years later, we still suffer from this...daily.
To avoid you some headaches with systems no one masters I will give examples in both worlds, Unix and Windows. OS X users are in the Unix world nowadays so they must follow the Unix examples.
In order to simplify display or print, each imapsync command line is usually written in several lines but it could be written in one single line.
If you prefer to use the whole command written in one single line then just remove the last visible character of each line ( \ or ^ ) and also the carriage return character. The last visible character means "command continues on next line"; it is the backslash \ character on Unix and the caret ^ character on Windows.
For example, on Unix, a command like the following
imapsync \ --host1 test.lamiral.info \ --user1 test1 \ --password1 secret1 \ ...
is equivalent to
imapsync --host1 test.lamiral.info --user1 test1 --password1 secret1 ...
and on Windows
imapsync.exe ^ --host1 test.lamiral.info ^ --user1 test1 ^ --password1 secret1 ^ ...
is equivalent to
imapsync --host1 test.lamiral.info --user1 test1 --password1 secret1 ...
A little explanation about this hint.
Imapsync is safe with accounts on host1,
it doesn't change anything on them, it just read them.
The exception of this safe principle is when
--delete1 option is used,
--delete1 removes on host1 each message successfully copied to host2,
messages that couldn't be transferred stay on host1.
It's not the same for destination accounts as imapsync writes on host2 accounts. Imapsync creates folders on them, add messages, set flags on messages. It isn't a safe behavior on a real account. So don't use a real user account to test imapsync. Learn to use it and see what it does on a test account at host2.
What can badly happen? The most common bad behavior is
the folders mapping won't be what you expect because it is strictly
reproduced from host1 to host2. The second bad behavior is
duplicates on second run and after, it's rare but it can happen
when a imap server software changes headers "
Message-Id" or "
Solutions to avoid duplicates are often easy (There's a FAQ called
FAQ.Duplicates.txt about that).
It's also possible to remove the duplicates on host2 but it's better to avoid them on user accounts at first,
users won't like that you mess up their mailboxes.
By default, unless explicitly told to do something else:
Imapsync has many options but you can ignore most of them and still make great transfers.
--dryetc. (using one minus, like
-dry, is ok)
1, like in
2, like in
source.example.com, (the value is