LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-29-2015, 04:06 PM   #1
Toasterman
Member
 
Registered: Oct 2013
Posts: 77

Rep: Reputation: Disabled
Noob needs to migrate mail server with imapsync


Hello all, I need to migrate a number of users from one mail server to another. I found a sample script online which I modified according to my needs:

Code:
mkdir -p LOG

{ while IFS=';' read  u1 p1 u2 p2
    do
         { echo "$u1" | egrep "^#" ; } > /dev/null && continue
         NOW=`date +%Y_%m_%d_%H_%M_%S`
         echo syncing to user "$u2"
         imapsync --useheader 'Message-Id' --useheader 'Message-ID' --useheader 'Received' \
                  --host1 imap.side1.org --user1 "$u1" --password1 "$p1" \
                  --host2 imap.side2.org --user2 "$u2" --password2 "$p2" \
                  --useheader 'Message-ID' \
                  --useheader 'References' \
                  --useheader 'Received' \
                  --useheader 'Subject' \
                  --subscribe \
                  --skipsize \
                  --usecache \
                  > LOG/log_${u2}_$NOW.txt 2>&1
    done
} < file.txt
The file.txt file has the usernames and passwords in this format:

Code:
user001_1;password001_1;user001_2;password001_2
    user002_1;password002_1;user002_2;password002_2
I have a few questions as I have never used this program before. The official page has been helpful but there are a few things that aren't answered in plain English.
1) Will my script copy everything or just the inbox? (e.g. Templates, drafts, sent)
2) This won't delete anything on the source machine, will it? I want to keep everything on the source machine until I'm absolutely sure the new one is working perfectly.
3) Lets say the machine running the scripts suddenly disconnects from the network and so the script ends in an error. If I start the script again, will it skip over the messages that were already copied or will I end up with duplicates? Certain forum posts I've read seem to suggest that some people have gotten duplicates but not others, depending on the options.
4) Is there anything that can be done to make this more efficient?

EDIT:
I attempted to sync an email account as a test. It didn't delete or duplicate any messages. It copied everything perfectly: templates, sent, inbox, etc. I still have a question about #4 though. The total file size I need to copy is about 160GB.

Last edited by Toasterman; 01-30-2015 at 01:13 PM.
 
Old 01-31-2015, 05:32 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Toasterman View Post
EDIT:
I attempted to sync an email account as a test. It didn't delete or duplicate any messages. It copied everything perfectly: templates, sent, inbox, etc.
Thanks for posting your experiences as I'm sure it will help others.


Quote:
Originally Posted by Toasterman View Post
I still have a question about #4 though. The total file size I need to copy is about 160GB.
In no particular order and without any regard for (in)feasibility:
- Empty thrash cans before transfer,
- Archive and compress the whole IMAP tree and process locally,
- Delete unwanted items before transferring,
- Use a tool that can provide compression during transfer,
- Allot or guarantee bandwidth during transfer,
- And see the imapsync FAQ: "How can I speed up transfers?".
 
Old 02-02-2015, 09:24 AM   #3
Toasterman
Member
 
Registered: Oct 2013
Posts: 77

Original Poster
Rep: Reputation: Disabled
Thank you. There are about 80 email accounts I have to transfer though so deleting the trash on each one might take more time than it would just to copy it.
I copied the same few accounts multiple times and it looks like only the new messages are getting copied, so that's good.

EDIT:
I noticed a quirk with subfolders of the inbox. Instead of copying them to the same location, it will create a new folder called INBOX and put the folders under that.

Last edited by Toasterman; 02-02-2015 at 10:01 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Migrate mail from one server to another with imapsync LXer Syndicated Linux News 0 10-11-2013 07:00 PM
LXer: How To Migrate Mailboxes Between IMAP Servers With imapsync LXer Syndicated Linux News 0 06-03-2009 06:10 PM
Migrate mail,ftp,squid and firewall to new server asaguru Linux - Server 0 10-10-2007 05:46 AM
help, noob mail server remisan Linux - Newbie 2 08-25-2005 09:36 PM
Noob's mail server problem J_Szucs Linux - Software 1 08-13-2003 03:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration