Addition/Migrate.to.New.iRedMail.Server

From iRedMail

(Difference between revisions)
Jump to: navigation, search
(Migrate mailboxes)
Line 43: Line 43:
Note: You can find all upgrade tutorials here: http://www.iredmail.org/doc.html#upgrade_tutorial
Note: You can find all upgrade tutorials here: http://www.iredmail.org/doc.html#upgrade_tutorial
 +
 +
== MySQL: Migrate mail accounts ==
== Migrate mailboxes (in maildir format) ==
== Migrate mailboxes (in maildir format) ==

Revision as of 14:43, 23 November 2011

Contents


TO BE CONTINUED.

Please try it on a test server first, if it works well, then try it on product server.

Since new iRedMail server will install same components as old server, you can choose what data you want to migrate. The major data are mail accounts, roundcube webmail database, mailboxes.


LDAP: migrate mail accounts

Steps to migrate LDAP mail accounts:

  • Setup a new server with the latest iRedMail, and make iRedAdmin-Pro-LDAP work as expected.
  • Export mail accounts from LDAP on OLD mail server.

Normally, LDAP data can be exported into LDIF format. Here's backup/export script: http://www.iredmail.org/wiki/index.php?title=IRedMail/FAQ/Backup

After exported from old server, you will get a plain text file which has LDIF data. You should remove top some items, includes:

  • dc=xxx,dc=xxx
  • cn=vmail,dc=xxx,dc=xxx
  • cn=vmailadmin,dc=xxx,dc=xxx
  • o=domains,dc=xxx,dc=xxx

Because we will use these ldap objects on new server, so remove them from exported data.

Assume the exported backup data is saved in file /root/old.ldif

  • Now, log into phpLDAPadmin with cn=Manager,dc=xxx,dc=xxx on NEW server, remove object of your mail domain. it should be:
    • domainName=your_domain.com,o=domains,dc=xxx,dc=xxx
  • Remove all sub-objects under this object.
  • Import /root/old.ldif with phpLDAPadmin.

You can find a button named "Import" in phpLDAPadmin left panel.

Note: You can find all upgrade tutorials here: http://www.iredmail.org/doc.html#upgrade_tutorial

MySQL: Migrate mail accounts

Migrate mailboxes (in maildir format)

  • Simply copy all mailboxes (in maildir format) to new iRedMail server.

WARNING: please make sure maildir path which stored/configured in LDAP will match the real path on file system, so that mail clients can find them.


This step is REQUIRED if you migrated mailboxes with iRedMail MySQL backend. Otherwise Dovecot will delete records in table vmail.mailbox to re-calculate mailbox quota.


Here's simple tutorial for your reference:

1) List all migrated users' email address in a plain text file, one address per line. Assume this file is /root/all_migrated_users.list.

2) Create shell script /root/get_sql_commands.sh with below content.

Terminal:
while read email; do
    cat >> /root/result.sql <<EOF
UPDATE mailbox SET bytes=-1,messages=-1 WHERE username="${email}";
EOF
done < /root/all_migrated_users.list

3) Execute this shell script. As shown in shell code, it will create a file named "result.sql" under directory /root.

Terminal:
# bash /root/get_sql_commands.sh

4) Import this SQL file to update SQL table, it will force Dovecot to re-calculate migrated users' mailbox quota when user first login to Roundcube webmail (or access mailbox via other IMAP clients).

Terminal:
# mysql -uroot -p
mysql> USE vmail;
mysql> SOURCE /root/result.sql;

Migrate Roundcube webmail data

  • Export/import roundcube webmail database, and upgrade database to work with new version of Roundcube.

http://trac.roundcube.net/wiki/Howto_Upgrade

Personal tools