imapsync 實現兩個不同郵件域內郵箱的遷移和備份

來源:互聯網
上載者:User

標籤:mail imapsync

前言:

   由於公司的舊的郵件伺服器作業系統版本太低,所以升級到了一個新的操作版本後,我們在新的伺服器上部署好了不同郵件域(臨時的)的郵件伺服器,為了減小對業務的影響,我們先停止業務對郵件伺服器的更新,並使用imapsync將原來的郵件伺服器的所有郵箱都遷移到新的郵件伺服器上,遷移速度很快,遷移完成後,我們測試下新的郵件伺服器,當可以正常使用的時候,我們切換新的網域名稱到新郵件伺服器上。


imapsync是啥?

    imapsync可以實現郵件伺服器遷移,支援 IMAP 的郵箱,它用於同步兩個imap郵箱 (僅適合遷移郵箱或者備份,不適合約步兩個有使用者同時訪問的 imap 帳號)

    安裝 imapsync (可以裝在要同步的任意一台伺服器上,也可以裝在第三方的伺服器上),這裡我們安裝到新郵件伺服器上,使用下面的命令:   

    yum install imapsync


imapsync的使用可以執行“imapsync --help”進行查看,因為很簡單,所以下面提供一個參考的例子:


#!/bin/bash - 

#usage: time /$path/imapsync_mail.sh > /root/sync_mail.log

mail_accounts=(

zhangdh1113

lance

linuxblind

)

accounts_passwd=(

‘[email protected]‘

‘[email protected]‘

‘[email protected]‘

)


i=0

while [ $i -lt ${#mail_accounts[@]} ];do

#    uid=`id -u ${mail_accounts[$i]} 2>/dev/null`

#    if [ $? -eq 0 ]; then

#          echo "usesrname \"${mail_accounts[$i]}\" already exist with its id \"$uid\"" >&2

#          exit 1

#    fi  

#    useradd ${mail_accounts[$i]}

#    echo "${accounts_passwd[$i]}" |passwd --stdin ${mail_accounts[$i]}

#    echo "user \"${mail_accounts[$i]}\" was created successfully!"

    #userdel ${mail_accounts[$i]}

    #rm -rf /home/${mail_accounts[$i]}

    /usr/bin/imapsync --host1 mail.a.com --user1 ${mail_accounts[$i]} --password1  ${accounts_passwd[$i]} --host2 mail.b.com --user2 ${mail_accounts[$i]} --password2 ${accounts_passwd[$i]} --delete2folders --delete2 >> /root/imap_sync.log 2>> /root/imap_sync.error.log

    let i++

done


exit 0



當然,某些情況下,mb2md.pl工具也能實現這個功能。

本文出自 “zhangdh開放空間” 部落格,請務必保留此出處http://linuxblind.blog.51cto.com/7616603/1711920

imapsync 實現兩個不同郵件域內郵箱的遷移和備份

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.