I hope you liked the previous article about the migration method-1. In this article, we will discuss another method of migration in detail.
Overview Of Method-2
This method involves many steps from method-1. The main difference between method-1 and method-2 is the email data migration process. In this method, we will use a third server other than the old and new servers to facilitate the email data migration process. Let me give you an illustrated overview of the steps of this method. If you have read the article about method-1, it will be easy for you to relate to and follow the steps.
Service Migration Followed By Data Migration – (Method-2)
As you can see from the image in the overview section, method-2 is almost similar to method-1. The only difference is the Email data migration process.
Please follow the previous article from step-1 to step-4 to complete the service migration process.
So with the above-mentioned steps, your service is shifted to the new server along with all users except their email data.
Now we will work on the email data migration process.
Step – 5
Email Data Migration Using Imapsync Server
We will use a
imapsync server to complete this step. What
imapsync server is going to do in this scenario? Check the illustration:
You have to ensure good connectivity between the old server to the imapsync server and the new server to the imapsync server.
Let’s take a look at how we can set up a
imapsync server in ubuntu. You can find lot’s of
imapsync installation documentation on the web. We are sharing a sample of
imapsync configuration with you:
apt-get install git rcs make makepasswd cpanminus apt-get install gcc libssl-dev libauthen-ntlm-perl libclass-load-perl libcrypt-ssleay-perl liburi-perl libdata-uniqid-perl libdigest-hmac-perl libdist-checkconflicts-perl libfile-copy-recursive-perl libio-compress-perl libio-socket-inet6-perl libio-socket-ssl-perl libio-tee-perl libmail-imapclient-perl libmodule-scandeps-perl libnet-ssleay-perl libpar-packer-perl libreadonly-perl libsys-meminfo-perl libterm-readkey-perl libtest-fatal-perl libtest-mock-guard-perl libtest-pod-perl libtest-requires-perl libtest-simple-perl libunicode-string-perl sudo cpanm Crypt::OpenSSL::RSA Crypt::OpenSSL::Random --force sudo cpanm Mail::IMAPClient JSON::WebToken Test::MockObject sudo cpanm Unicode::String Data::Uniqid sudo cpanm Encode::IMAPUTF7 module sudo cpanm Regexp::Common module sudo cpanm File::Tail module git clone https://github.com/imapsync/imapsync.git cd imapsync mkdir -p dist sudo make install
Now, we have a ready-to-go
imapsync server. Let’s start the email data transfer process.
[Execute the command from the system directory of imapsync] ./imapsync --host1 mail.oldserver.com --user1 email@example.com --password1 123456 --host2 mail.newserver.com --user2 firstname.lastname@example.org --password2 123456
If everything works fine, you will get an out like this:
root@mail:~/imapsync# ./imapsync --host1 mail.oldserver.com --user1 arman --password1 123456 --host2 mail.newserver.com --user2 arman --password2 123456 Here is imapsync 2.200 on host mail, a linux system with 6.3/7.7 free GiB of RAM with Perl 5.30.0 and Mail::IMAPClient 3.43 Transfer started at Thursday 18 August 2022-08-18 14:22:57 +0000 UTC PID is 4324 my PPID is 2795 Log file is LOG_imapsync/2022_08_18_14_22_57_507_arman_arman.txt ( to change it, use --logfile path ; or use --nolog to turn off logging ) Load is 0.20 0.19 0.18 2/253 on 2 cores Current directory is /root/imapsync Real user id is root (uid 0) Effective user id is root (euid 0) $RCSfile: imapsync,v $ $Revision: 2.200 $ $Date: 2022/04/04 16:05:55 $ Command line used, run by /usr/bin/perl: ./imapsync --host1 mail.oldserver.com --user1 arman --password1 MASKED --host2 mail.newserver.com --user2 arman --password2 MASKED Temp directory is /tmp ( to change it use --tmpdir dirpath ) kill -QUIT 4324 # special behavior: call to sub catch_exit kill -TERM 4324 # special behavior: call to sub catch_exit kill -INT 4324 # special behavior: call to sub catch_reconnect kill -HUP 4324 # special behavior: call to sub catch_print kill -USR1 4324 # special behavior: call to sub toggle_sleep File /tmp/imapsync.pid does not exist PID file is /tmp/imapsync.pid ( to change it, use --pidfile filepath ; to avoid it use --pidfile "" ) Writing my PID 4324 in /tmp/imapsync.pid Writing also my logfile name in /tmp/imapsync.pid : LOG_imapsync/2022_08_18_14_22_57_507_arman_arman.txt Modules version list ( use --no-modulesversion to turn off printing this Perl modules list ): [Output concatenated] Time spent on sizing: 0.3 seconds ++++ Statistics Transfer started on : Thursday 18 August 2022-08-18 14:22:57 +0000 UTC Transfer ended on : Thursday 18 August 2022-08-18 14:23:10 +0000 UTC Transfer time : 13.0 sec Folders synced : 6/6 synced Messages transferred : 94 Messages skipped : 0 Messages found duplicate on host1 : 0 Messages found duplicate on host2 : 0 Messages found crossduplicate on host2 : 0 Messages void (noheader) on host1 : 0 Messages void (noheader) on host2 : 0 Messages found in host1 not in host2 : 0 messages Messages found in host2 not in host1 : 0 messages Messages deleted on host1 : 0 Messages deleted on host2 : 0 Total bytes transferred : 10941499 (10.435 MiB) Total bytes skipped : 0 (0.000 KiB) Message rate : 7.2 messages/s Average bandwidth rate : 820.0 KiB/s Reconnections to host1 : 0 Reconnections to host2 : 0 Memory consumption at the end : 207.8 MiB (started with 169.2 MiB) Load end is : 0.22 0.20 0.18 1/253 on 2 cores CPU time and %cpu : 1.88 sec 14.4 %cpu 7.2 %allcpus Biggest message transferred : 9833486 bytes (9.378 MiB) Memory/biggest message ratio : 22.2 Start difference host2 - host1 : -94 messages, -10941499 bytes (-10.435 MiB) Final difference host2 - host1 : 0 messages, 94 bytes (0.092 KiB) The sync looks good, all 94 identified messages in host1 are on host2. There is no unidentified message on host1. The sync is strict, all 94 identified messages in host2 are on host1. Detected 0 errors Check if a new imapsync release is available by adding --releasecheck Homepage: https://imapsync.lamiral.info/ Host2: Successfully put the email final report in INBOX. Use --noemailreport2 to avoid it. Host1: Successfully put the email final report in INBOX. Use --noemailreport1 to avoid it. Exiting with return value 0 (EX_OK: successful termination) 0/50 nb_errors/max_errors PID 4324 Removing pidfile /tmp/imapsync.pid Log file is LOG_imapsync/2022_08_18_14_22_57_507_arman_arman.txt ( to change it, use --logfile filepath ; or use --nolog to turn off logging ) root@mail:~/imapsync#
Now you can see your old messages on your new account on the new server.
You can find more details about
As I have mentioned earlier, if you feel your server infrastructure is a bit complex to manage and need the expertise to help you to migrate, you can always check other options. i.e (zextras suite)
So that’s it for today.
Hello. If it is useful, with imapsync, I use the --authuser option. In the middle of migration of thousands of users, I preffer use the admin password in host1 and host2 this way: ***SCRIPT_INI*** #!/usr//bin/bash host1= # host1 IP is Source host2= # host2 IP is Dest admin1="email@example.com" admin2="adminuser2.dominio2.com" admpass1="PASSadminuser1" admpass2="PASSadminuser2" time imapsync --syncinternaldates \ --host1 $host1 --user1 "firstname.lastname@example.org" --authuser1 "$admin1" --password1 "$admpass1" --ssl1 \ --host2 $host2 --user2 "email@example.com" --authuser2 "$admin2" --password2 "$admpass2" --ssl2 ***SCRIPT_END*** I hope to help. Regards.
@jaimeco Absolutely yes, this is the best solution to migrate from server A to B but it works only if you can use an admin user with delegate access ( not all imap server allow you to use delegate access method ).
Why not move the data and update zimbra version? It's a dns problem, logs say can't resolve imap server.