移機或備份

  1. 在新主機上安裝必要套件。
    [root@dns ~]# yum install roundcubemail postfix dovecot mysql-server
    
  2. 備份用戶郵件、 mysql 資料庫、roundcubemail 程式、postfix, dovecot, roundcubemail 設定檔案。
    [root@mail ~]# rsync -av /var/lib/mysql 163.17.10.1:/var/lib/
    [root@mail ~]# rsync -av /etc/{postfix,dovecot,roundcubemail} 163.17.10.1:/etc/
    [root@mail ~]# rsync -av /usr/share/roundcubemail 163.17.10.1:/usr/share/
    [root@mail ~]# rsync -av --exclude=root --exclude=lost+found --exclude=rpc \
    /var/spool/mail 163.17.10.1:/var/spool/
    
  3. 修改 postfix 主設定檔的主機名稱。
    [root@dns ~]# grep csie.cyut.edu.tw /etc/postfix/main.cf
    myhostname = csie.cyut.edu.tw
    mydomain = csie.cyut.edu.tw
    
  4. 設定 dovecot postmaster_address
    [root@dns ~]# grep csie.cyut.edu.tw /etc/dovecot/dovecot.conf 
    postmaster_address=postmaster at csie.cyut.edu.tw
    
  5. 修改 roundcubemail 預設 mail server 主機,此設定也會影響 roundcubemail 登入。
    [root@dns ~]# vim /etc/roundcubemail/config.inc.php
    [root@dns ~]# grep csie.cyut.edu.tw /etc/roundcubemail/config.inc.php
    $config['default_host'] = "csie.cyut.edu.tw";
    
  6. roundcubemail 登入帳號在 mysql 資料庫中以 username, mail_host 兩個欄位做斷判,備份到新主機的資料庫如果不修改,由於郵件主機不同,因此登入時會新產生一筆帳號。上一動作將 roundcubemail 預設 mail server 改成 csie.cyut.edu.tw,mysql 資料庫 roundcubemail 帳號中的 mail_host 也必須改成 csie.cyut.edu.tw,這樣才能使用原有帳號的設定。
    [root@dns ~]# mysql -uroot -pxxxxxx -e "use roundcube; \
    update users set mail_host='csie.cyut.edu.tw' \
    where mail_host='mail.csie.cyut.edu.tw';"